Index: flag.install =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/flag/Attic/flag.install,v retrieving revision 1.2.2.32.2.4 diff -u -r1.2.2.32.2.4 flag.install --- flag.install 26 Oct 2009 21:31:13 -0000 1.2.2.32.2.4 +++ flag.install 26 Oct 2009 21:40:46 -0000 @@ -212,7 +212,7 @@ ), 'primary key' => array('fcid'), 'unique keys' => array( - 'fid_content_type_content_id_uid' => array('fid', 'content_type', 'content_id', 'uid'), + 'fid_content_id_uid' => array('fid', 'content_id', 'uid'), ), 'indexes' => array( 'content_type_content_id' => array('content_type', 'content_id'), @@ -274,6 +274,7 @@ 'indexes' => array( 'fid_content_type' => array('fid', 'content_type'), 'content_type_content_id' => array('content_type', 'content_id'), + 'count' => array('count'), ), ); @@ -482,6 +483,25 @@ return $ret; } +/** + * Refine the indexes. + * + * The content type inclusion actually slowed down on unique key. And a count + * index would be helpful for sorting by counts. + */ +function flag_update_6201() { + $ret = array(); + + // Remove "content type" from one key, see http://drupal.org/node/612602. + db_drop_unique_key($ret, 'flag_content', 'fid_content_type_content_id_uid'); + db_add_unique_key($ret, 'flag_content', 'fid_content_id_uid', array('fid', 'content_id', 'uid')); + + // Add a count index, see http://drupal.org/node/489610. + db_add_index($ret, 'flag_counts', 'count', array('count')); + + return $ret; +} + // This is a replacement for update_sql(). The latter doesn't support placeholders. function _flag_update_sql($sql) { $args = func_get_args();