r25956 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r25955‎ | r25956 | r25957 >
Date:09:47, 20 September 2007
Author:proes
Status:old
Tags:
Comment:
Renamed "Recreate indexes for all tables.php" to "Recreate indexes for tables for website.php". This, to make a difference between indexes that are useful for the performance of an on line website and indexes that are useful during an import script.
Modified paths:
  • /trunk/extensions/Wikidata/Database+scripts/Convenience/Recreate+indexes+for+all+tables+for+website.php (added) (history)
  • /trunk/extensions/Wikidata/Database+scripts/Convenience/Recreate+indexes+for+all+tables+for+website.php (added) (history)
  • /trunk/extensions/Wikidata/Database+scripts/Convenience/Recreate+indexes+for+all+tables.php (deleted) (history)

Diff [purge]

Index: trunk/extensions/Wikidata/Database scripts/Convenience/Recreate indexes for all tables.php
@@ -1,95 +0,0 @@
2 -<?php
3 -
4 -define('MEDIAWIKI', true );
5 -
6 -require_once("../../../../StartProfiler.php");
7 -require_once("../../../../LocalSettings.php");
8 -require_once("../../php-tools/ProgressBar.php");
9 -require_once("DatabaseUtilities.php");
10 -require_once("Setup.php");
11 -
12 -ob_end_flush();
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 -
28 -function createIndexesForTable($dc,$tableName) {
29 - $handle = fopen("Create uw_" . $tableName . " indices.sql", "r");
30 - $sql = "";
31 -
32 - while (!feof($handle)) {
33 - $line = fgets($handle);
34 -
35 - if (substr($line, 0, 2) != "--")
36 - $sql .= $line;
37 - }
38 -
39 - $sql = str_replace("%dc%", $dc, $sql);
40 -
41 - $dbr =& wfGetDB(DB_MASTER);
42 - $queryResult = $dbr->query($sql);
43 -
44 - fclose($handle);
45 -}
46 -
47 -function recreateIndexesForTable($dc, $tableName) {
48 - echo "Dropping indices from table " . $dc . "_" . $tableName . ".\n";
49 - dropAllIndicesFromTable($dc . "_" . $tableName);
50 - echo "Creating new indices for table " . $dc . "_" . $tableName . ".\n";
51 - createIndexesForTable($dc,$tableName);
52 -}
53 -
54 -function recreateIndexesForTables($dc, $tableNames) {
55 - foreach ($tableNames as $tableName){
56 - recreateIndexesForTable($dc,$tableName);
57 - }
58 -}
59 -
60 -global
61 -$beginTime, $wgCommandLineMode;
62 -
63 -$beginTime = time();
64 -$wgCommandLineMode = true;
65 -$dc = "uw";
66 -
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",
76 - "defined_meaning",
77 - "expression",
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();
88 -
89 -foreach( $prefixes as $prefix ){
90 - recreateIndexesForTables( $prefix, $tables );
91 -}
92 -
93 -$endTime = time();
94 -echo("\n\nTime elapsed: " . durationToString($endTime - $beginTime));
95 -
96 -
Index: trunk/extensions/Wikidata/Database scripts/Convenience/Recreate indexes for all tables for website.php
@@ -0,0 +1,95 @@
 2+<?php
 3+
 4+define('MEDIAWIKI', true );
 5+
 6+require_once("../../../../StartProfiler.php");
 7+require_once("../../../../LocalSettings.php");
 8+require_once("../../php-tools/ProgressBar.php");
 9+require_once("DatabaseUtilities.php");
 10+require_once("Setup.php");
 11+
 12+ob_end_flush();
 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+
 28+function createIndexesForTable($dc,$tableName) {
 29+ $handle = fopen("Create uw_" . $tableName . " indices.sql", "r");
 30+ $sql = "";
 31+
 32+ while (!feof($handle)) {
 33+ $line = fgets($handle);
 34+
 35+ if (substr($line, 0, 2) != "--")
 36+ $sql .= $line;
 37+ }
 38+
 39+ $sql = str_replace("%dc%", $dc, $sql);
 40+
 41+ $dbr =& wfGetDB(DB_MASTER);
 42+ $queryResult = $dbr->query($sql);
 43+
 44+ fclose($handle);
 45+}
 46+
 47+function recreateIndexesForTable($dc, $tableName) {
 48+ echo "Dropping indices from table " . $dc . "_" . $tableName . ".\n";
 49+ dropAllIndicesFromTable($dc . "_" . $tableName);
 50+ echo "Creating new indices for table " . $dc . "_" . $tableName . ".\n";
 51+ createIndexesForTable($dc,$tableName);
 52+}
 53+
 54+function recreateIndexesForTables($dc, $tableNames) {
 55+ foreach ($tableNames as $tableName){
 56+ recreateIndexesForTable($dc,$tableName);
 57+ }
 58+}
 59+
 60+global
 61+$beginTime, $wgCommandLineMode;
 62+
 63+$beginTime = time();
 64+$wgCommandLineMode = true;
 65+$dc = "uw";
 66+
 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",
 76+ "defined_meaning",
 77+ "expression",
 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();
 88+
 89+foreach( $prefixes as $prefix ){
 90+ recreateIndexesForTables( $prefix, $tables );
 91+}
 92+
 93+$endTime = time();
 94+echo("\n\nTime elapsed: " . durationToString($endTime - $beginTime));
 95+
 96+
Property changes on: trunk/extensions/Wikidata/Database scripts/Convenience/Recreate indexes for all tables for website.php
___________________________________________________________________
Added: svn:eol-style
197 + native

Status & tagging log