diff -wrU3 a/sites/all/modules/votingapi/votingapi.install b/sites/all/modules/votingapi/votingapi.install --- a/sites/all/modules/votingapi/votingapi.install 2007-06-29 16:41:56.000000000 -0400 +++ b/sites/all/modules/votingapi/votingapi.install 2008-06-03 18:23:29.000000000 -0400 @@ -271,6 +271,29 @@ return $ret; } +/** + * Improve indexing on MySQL. + */ + +function votingapi_update_10() { + $ret = array(); + switch ($GLOBALS['db_type']) { + case 'mysql': + case 'mysqli': + $ret[] = update_sql("ALTER TABLE {votingapi_vote} ADD KEY (tag);"); + $ret[] = update_sql("ALTER TABLE {votingapi_vote} ADD KEY (content_type, tag);"); + $ret[] = update_sql("ALTER TABLE {votingapi_vote} ADD KEY (content_type, value_type);"); + + $ret[] = update_sql("ALTER TABLE {votingapi_cache} ADD KEY (content_type, function);"); + $ret[] = update_sql("ALTER TABLE {votingapi_cache} ADD KEY (content_type, tag);"); + $ret[] = update_sql("ALTER TABLE {votingapi_cache} ADD KEY (content_type, value_type);"); + + break; + } + + return $ret; +} + function votingapi_uninstall() { db_query("DROP TABLE {votingapi_vote}"); db_query("DROP TABLE {votingapi_cache}"); diff -wrU3 a/sites/all/modules/votingapi/votingapi_views.inc b/sites/all/modules/votingapi/votingapi_views.inc --- a/sites/all/modules/votingapi/votingapi_views.inc 2007-06-29 16:41:56.000000000 -0400 +++ b/sites/all/modules/votingapi/votingapi_views.inc 2008-06-03 18:07:41.000000000 -0400 @@ -243,7 +243,7 @@ function _votingapi_views_values($field = 'tag', $table = 'vote') { static $cached; if (!isset($cached[$table][$field])) { - $results = db_query("SELECT DISTINCT %s FROM {votingapi_%s} WHERE content_type = 'node'", $field, $table); + $results = db_query("SELECT %s FROM {votingapi_%s} GROUP BY content_type, %s HAVING content_type = 'node'", $field, $table, $field); while ($result = db_fetch_object($results)) { $cached[$table][$field][$result->$field] = $result->$field; }