Index: trunk/extensions/Wikidata/Database scripts/Convenience/Recreate indexes for all tables.php |
— | — | @@ -10,6 +10,20 @@ |
11 | 11 | |
12 | 12 | ob_end_flush(); |
13 | 13 | |
| 14 | +/* |
| 15 | + * This function wil retrieve a list of the data sets defined in this |
| 16 | + * database and return it as an array |
| 17 | + */ |
| 18 | +function retrieve_datasets(){ |
| 19 | + $prefixes = array(); |
| 20 | + $dbr = &wfGetDB(DB_SLAVE); |
| 21 | + $queryResult = $dbr->query("select set_prefix from wikidata_sets"); |
| 22 | + while ($datasetRecord = $dbr->fetchObject($queryResult) ) { |
| 23 | + array_push( $prefixes, $datasetRecord->set_prefix ); |
| 24 | + } |
| 25 | + return $prefixes; |
| 26 | +} |
| 27 | + |
14 | 28 | function createIndexesForTable($dc,$tableName) { |
15 | 29 | $handle = fopen("Create uw_" . $tableName . " indices.sql", "r"); |
16 | 30 | $sql = ""; |
— | — | @@ -43,34 +57,38 @@ |
44 | 58 | } |
45 | 59 | |
46 | 60 | global |
47 | | - $beginTime, $wgCommandLineMode; |
| 61 | +$beginTime, $wgCommandLineMode; |
48 | 62 | |
49 | 63 | $beginTime = time(); |
50 | 64 | $wgCommandLineMode = true; |
51 | | -$dc = "sp"; |
| 65 | +$dc = "uw"; |
52 | 66 | |
53 | | -recreateIndexesForTables( "sp", |
54 | | - array( |
55 | | - "bootstrapped_defined_meanings", |
56 | | - "transactions", |
57 | | - "translated_content", |
58 | | - "alt_meaningtexts", |
59 | | - "class_attributes", |
60 | | - "class_membership", |
61 | | - "collection_contents", |
62 | | - "collection_ns", |
63 | | - "defined_meaning", |
64 | | - "expression_ns", |
65 | | - "meaning_relations", |
66 | | - "option_attribute_options", |
67 | | - "option_attribute_values", |
68 | | - "syntrans", |
69 | | - "text_attribute_values", |
70 | | - "translated_content_attribute_values", |
71 | | - "url_attribute_values" |
72 | | - ) |
73 | | -); |
| 67 | +$tables = array( |
| 68 | + "bootstrapped_defined_meanings", |
| 69 | + "transactions", |
| 70 | + "translated_content", |
| 71 | + "alt_meaningtexts", |
| 72 | + "class_attributes", |
| 73 | + "class_membership", |
| 74 | + "collection_contents", |
| 75 | + "collection_ns", |
| 76 | + "defined_meaning", |
| 77 | + "expression_ns", |
| 78 | + "meaning_relations", |
| 79 | + "option_attribute_options", |
| 80 | + "option_attribute_values", |
| 81 | + "syntrans", |
| 82 | + "text_attribute_values", |
| 83 | + "translated_content_attribute_values", |
| 84 | + "url_attribute_values" |
| 85 | + ); |
| 86 | + |
| 87 | +$prefixes = retrieve_datasets(); |
74 | 88 | |
| 89 | +foreach( $prefixes as $prefix ){ |
| 90 | + recreateIndexesForTables( $prefix, $tables ); |
| 91 | +} |
| 92 | + |
75 | 93 | $endTime = time(); |
76 | 94 | echo("\n\nTime elapsed: " . durationToString($endTime - $beginTime)); |
77 | 95 | |