http://www.mediawiki.org/wiki/Special:Code/MediaWiki/97998

Revision: 97998
Author:   catrope
Date:     2011-09-24 12:50:22 +0000 (Sat, 24 Sep 2011)
Log Message:
-----------
MoodBar: Add mbf_id to the end of all indexes so we can do proper, indexed, 
sorted paging by timestamp and ID.

Modified Paths:
--------------
    trunk/extensions/MoodBar/MoodBar.hooks.php
    trunk/extensions/MoodBar/sql/MoodBar.sql

Added Paths:
-----------
    trunk/extensions/MoodBar/sql/AddIDToIndexes.sql
    trunk/extensions/MoodBar/sql/AddIDToIndexes2.sql
    trunk/extensions/MoodBar/sql/mbf_timestamp_id.sql

Removed Paths:
-------------
    trunk/extensions/MoodBar/sql/mbf_timestamp.sql

Modified: trunk/extensions/MoodBar/MoodBar.hooks.php
===================================================================
--- trunk/extensions/MoodBar/MoodBar.hooks.php  2011-09-24 12:30:53 UTC (rev 
97997)
+++ trunk/extensions/MoodBar/MoodBar.hooks.php  2011-09-24 12:50:22 UTC (rev 
97998)
@@ -75,8 +75,18 @@
                        'mbf_user_editcount', 
dirname(__FILE__).'/sql/mbf_user_editcount.sql', true )
                );
                
+               $db = $updater->getDB();
+               if ( $db->indexExists( 'moodbar_feedback', 'type_timestamp', 
__METHOD__ ) ) {
+                       $updater->addExtensionUpdate( array( 'addIndex', 
'moodbar_feedback',
+                               'mbf_type_timestamp_id', dirname( __FILE__ ) . 
'/sql/AddIDToIndexes.sql', true )
+                       );
+               }
+               $updater->addExtensionUpdate( array( 'dropIndex', 
'moodbar_feedback',
+                       'mbf_timestamp', dirname( __FILE__ ) . 
'/sql/AddIDToIndexes2.sql', true )
+               );
+               
                $updater->addExtensionUpdate( array( 'addIndex', 
'moodbar_feedback',
-                       'mbf_timestamp', dirname( __FILE__ ) . 
'/sql/mbf_timestamp.sql', true )
+                       'mbf_timestamp_id', dirname( __FILE__ ) . 
'/sql/mbf_timestamp_id.sql', true )
                );
 
                return true;

Added: trunk/extensions/MoodBar/sql/AddIDToIndexes.sql
===================================================================
--- trunk/extensions/MoodBar/sql/AddIDToIndexes.sql                             
(rev 0)
+++ trunk/extensions/MoodBar/sql/AddIDToIndexes.sql     2011-09-24 12:50:22 UTC 
(rev 97998)
@@ -0,0 +1,5 @@
+-- Drop and recreate indexes to add mbf_id to the end
+DROP INDEX /*i*/type_timestamp ON /*_*/moodbar_feedback;
+DROP INDEX /*i*/title_type ON /*_*/moodbar_feedback;
+CREATE INDEX /*i*/mbf_type_timestamp_id ON /*_*/moodbar_feedback 
(mbf_type,mbf_timestamp, mbf_id);
+CREATE INDEX /*i*/mbf_title_type_id ON /*_*/moodbar_feedback 
(mbf_namespace,mbf_title,mbf_type,mbf_timestamp, mbf_id);
\ No newline at end of file


Property changes on: trunk/extensions/MoodBar/sql/AddIDToIndexes.sql
___________________________________________________________________
Added: svn:eol-style
   + native

Added: trunk/extensions/MoodBar/sql/AddIDToIndexes2.sql
===================================================================
--- trunk/extensions/MoodBar/sql/AddIDToIndexes2.sql                            
(rev 0)
+++ trunk/extensions/MoodBar/sql/AddIDToIndexes2.sql    2011-09-24 12:50:22 UTC 
(rev 97998)
@@ -0,0 +1,5 @@
+-- Drop and recreate indexes to add mbf_id to the end
+DROP INDEX /*i*/mbf_userid_ip_timestamp ON /*_*/moodbar_feedback;
+DROP INDEX /*i*/mbf_type_userid_ip_timestamp ON /*_*/moodbar_feedback;
+DROP INDEX /*i*/mbf_timestamp ON /*_*/moodbar_feedback;
+-- Recreation is done in mbf_timestamp_id.sql


Property changes on: trunk/extensions/MoodBar/sql/AddIDToIndexes2.sql
___________________________________________________________________
Added: svn:eol-style
   + native

Modified: trunk/extensions/MoodBar/sql/MoodBar.sql
===================================================================
--- trunk/extensions/MoodBar/sql/MoodBar.sql    2011-09-24 12:30:53 UTC (rev 
97997)
+++ trunk/extensions/MoodBar/sql/MoodBar.sql    2011-09-24 12:50:22 UTC (rev 
97998)
@@ -26,9 +26,9 @@
 ) /*$wgDBTableOptions*/;
 
 -- A little overboard with the indexes perhaps, but we want to be able to dice 
this data a lot!
-CREATE INDEX /*i*/type_timestamp ON /*_*/moodbar_feedback 
(mbf_type,mbf_timestamp);
-CREATE INDEX /*i*/title_type ON /*_*/moodbar_feedback 
(mbf_namespace,mbf_title,mbf_type,mbf_timestamp);
--- CREATE INDEX /*i*/mbf_namespace_title_timestamp ON /*_*/moodbar_feedback 
(mbf_namespace, mbf_title, mbf_timestamp); --maybe in the future if we actually 
do per-page filtering
-CREATE INDEX /*i*/mbf_userid_ip_timestamp ON /*_*/moodbar_feedback 
(mbf_user_id, mbf_user_ip, mbf_timestamp);
-CREATE INDEX /*i*/mbf_type_userid_ip_timestamp ON /*_*/moodbar_feedback 
(mbf_type, mbf_user_id, mbf_user_ip, mbf_timestamp);
-CREATE INDEX /*i*/mbf_timestamp ON /*_*/moodbar_feedback (mbf_timestamp);
+CREATE INDEX /*i*/mbf_type_timestamp_id ON /*_*/moodbar_feedback 
(mbf_type,mbf_timestamp, mbf_id);
+CREATE INDEX /*i*/mbf_title_type_id ON /*_*/moodbar_feedback 
(mbf_namespace,mbf_title,mbf_type,mbf_timestamp, mbf_id);
+-- CREATE INDEX /*i*/mbf_namespace_title_timestamp ON /*_*/moodbar_feedback 
(mbf_namespace, mbf_title, mbf_timestamp, mbf_id); --maybe in the future if we 
actually do per-page filtering
+CREATE INDEX /*i*/mbf_userid_ip_timestamp_id ON /*_*/moodbar_feedback 
(mbf_user_id, mbf_user_ip, mbf_timestamp, mbf_id);
+CREATE INDEX /*i*/mbf_type_userid_ip_timestamp_id ON /*_*/moodbar_feedback 
(mbf_type, mbf_user_id, mbf_user_ip, mbf_timestamp, mbf_id);
+CREATE INDEX /*i*/mbf_timestamp_id ON /*_*/moodbar_feedback (mbf_timestamp, 
mbf_id);

Deleted: trunk/extensions/MoodBar/sql/mbf_timestamp.sql
===================================================================
--- trunk/extensions/MoodBar/sql/mbf_timestamp.sql      2011-09-24 12:30:53 UTC 
(rev 97997)
+++ trunk/extensions/MoodBar/sql/mbf_timestamp.sql      2011-09-24 12:50:22 UTC 
(rev 97998)
@@ -1,5 +0,0 @@
--- Add some indexes to the moodbar_feedback table
-
-CREATE INDEX /*i*/mbf_userid_ip_timestamp ON /*_*/moodbar_feedback 
(mbf_user_id, mbf_user_ip, mbf_timestamp);
-CREATE INDEX /*i*/mbf_type_userid_ip_timestamp ON /*_*/moodbar_feedback 
(mbf_type, mbf_user_id, mbf_user_ip, mbf_timestamp);
-CREATE INDEX /*i*/mbf_timestamp ON /*_*/moodbar_feedback (mbf_timestamp);

Copied: trunk/extensions/MoodBar/sql/mbf_timestamp_id.sql (from rev 97990, 
trunk/extensions/MoodBar/sql/mbf_timestamp.sql)
===================================================================
--- trunk/extensions/MoodBar/sql/mbf_timestamp_id.sql                           
(rev 0)
+++ trunk/extensions/MoodBar/sql/mbf_timestamp_id.sql   2011-09-24 12:50:22 UTC 
(rev 97998)
@@ -0,0 +1,5 @@
+-- Add some indexes to the moodbar_feedback table
+
+CREATE INDEX /*i*/mbf_userid_ip_timestamp_id ON /*_*/moodbar_feedback 
(mbf_user_id, mbf_user_ip, mbf_timestamp, mbf_id);
+CREATE INDEX /*i*/mbf_type_userid_ip_timestamp_id ON /*_*/moodbar_feedback 
(mbf_type, mbf_user_id, mbf_user_ip, mbf_timestamp, mbf_id);
+CREATE INDEX /*i*/mbf_timestamp_id ON /*_*/moodbar_feedback (mbf_timestamp, 
mbf_id);


_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to