Closed (won't fix)
Project:
Drupal core
Version:
6.x-dev
Component:
menu system
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
9 Feb 2009 at 14:45 UTC
Updated:
8 May 2013 at 14:58 UTC
mysql> explain SELECT menu_name FROM menu_links WHERE expanded != 0 GROUP BY menu_name;
+----+-------------+------------+-------+---------------+------------------------+---------+------+------+--------------------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+------------+-------+---------------+------------------------+---------+------+------+--------------------------+
| 1 | SIMPLE | menu_links | index | NULL | menu_plid_expand_child | 106 | NULL | 5214 | Using where; Using index |
+----+-------------+------------+-------+---------------+------------------------+---------+------+------+--------------------------+
1 row in set (0.00 sec)
mysql> alter table menu_links add index expanded (expanded);
Query OK, 5069 rows affected (0.74 sec)
Records: 5069 Duplicates: 0 Warnings: 0
mysql> explain SELECT menu_name FROM menu_links WHERE expanded != 0 GROUP BY menu_name;
+----+-------------+------------+-------+---------------+----------+---------+------+------+----------------------------------------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+------------+-------+---------------+----------+---------+------+------+----------------------------------------------+
| 1 | SIMPLE | menu_links | range | expanded | expanded | 2 | NULL | 2 | Using where; Using temporary; Using filesort |
+----+-------------+------------+-------+---------------+----------+---------+------+------+----------------------------------------------+
Comments
Comment #1
robertdouglass commentedsubscribbe
Comment #2
irakli commentedUsing good-old DISTINCT instead of Group By can further optimize by removing the "filesort":
Comment #3
david straussThe index should be on (expanded, menu_name), and the query should be rewritten to use greater than, less than, or equality instead of "!=". Agreed on the use of DISTINCT. If we do all that, we should eliminate the temp table, too.
Comment #4
multiplextor commentedClosed. The reason: expired.
Comment #4.0
multiplextor commentedadded code tags so you can read this