]> git.mjollnir.org Git - moodle.git/commitdiff
Adding one new index to cache_text table. User to make cron deletion
authorstronk7 <stronk7>
Mon, 8 Oct 2007 16:33:29 +0000 (16:33 +0000)
committerstronk7 <stronk7>
Mon, 8 Oct 2007 16:33:29 +0000 (16:33 +0000)
of expired records faster. MDL-11605

lib/db/install.xml
lib/db/upgrade.php

index 910cbae4a24e021cd332bea7eae6f78e2a54b7ff..1a8241306be1cc78c847c9c32f0b41f5cb2132b7 100644 (file)
         <KEY NAME="primary" TYPE="primary" FIELDS="id"/>
       </KEYS>
       <INDEXES>
-        <INDEX NAME="md5key" UNIQUE="false" FIELDS="md5key"/>
+        <INDEX NAME="md5key" UNIQUE="false" FIELDS="md5key" NEXT="timemodified"/>
+        <INDEX NAME="timemodified" UNIQUE="false" FIELDS="timemodified" COMMENT="Mainly to help deletion of expired records from cron" PREVIOUS="md5key"/>
       </INDEXES>
     </TABLE>
     <TABLE NAME="grade_category" COMMENT="to define categories to group activity grades" PREVIOUS="cache_text" NEXT="grade_exceptions">
index e68fc4dce92703c23a1fa0b9238273694d3c9c09..63b94b989230591347da0f83a8426784d2ae0ad7 100644 (file)
@@ -2400,6 +2400,21 @@ function xmldb_main_upgrade($oldversion=0) {
         $result = $result && drop_table($table);
     }
 
+/// Truncate the text_cahe table and add new index
+    if ($result && $oldversion < 2007100802) {
+
+    /// Truncate the cache_text table
+        execute_sql("TRUNCATE TABLE {$CFG->prefix}cache_text", true);
+
+    /// Define index timemodified (not unique) to be added to cache_text
+        $table = new XMLDBTable('cache_text');
+        $index = new XMLDBIndex('timemodified');
+        $index->setAttributes(XMLDB_INDEX_NOTUNIQUE, array('timemodified'));
+
+    /// Launch add index timemodified
+        $result = $result && add_index($table, $index);
+    }
+
     return $result;
 }