[wp-trac] Re: [WordPress Trac] #8561: query in meta_form() function
in /wp-admin/includes/template.php causes post/page editing to load
slowly
WordPress Trac
wp-trac at lists.automattic.com
Sat Apr 18 15:34:58 GMT 2009
#8561: query in meta_form() function in /wp-admin/includes/template.php causes
post/page editing to load slowly
--------------------------+-------------------------------------------------
Reporter: fastpipe | Owner: anonymous
Type: defect (bug) | Status: new
Priority: high | Milestone: 2.8
Component: Optimization | Version: 2.7
Severity: critical | Keywords: meta_key postmeta post page has-patch
--------------------------+-------------------------------------------------
Comment(by Denis-de-Bernardy):
patch is invalid. the group by is not the issue, and the distinct
statement can only end up adding an extra sort operator to the full query,
while doing the same as a group by.
the real issue is the order by meta_id desc. It should be order by
meta_key instead, so as to use the index during the group by:
{{{
mysql> explain extended select meta_key from wp_postmeta where meta_key
not like '\_%' group by meta_key order by meta_key limit 30;
+----+-------------+-------------+-------+---------------+----------+---------+------+------+---------------------------------------+
| id | select_type | table | type | possible_keys | key |
key_len | ref | rows | Extra |
+----+-------------+-------------+-------+---------------+----------+---------+------+------+---------------------------------------+
| 1 | SIMPLE | wp_postmeta | range | NULL | meta_key | 258
| NULL | 29 | Using where; Using index for group-by |
+----+-------------+-------------+-------+---------------+----------+---------+------+------+---------------------------------------+
1 row in set, 1 warning (0.00 sec)
mysql> explain extended select meta_key from wp_postmeta where meta_key
not like '\_%' group by meta_key order by meta_id limit 30;
+----+-------------+-------------+-------+---------------+---------+---------+------+------+------------------------------+
| id | select_type | table | type | possible_keys | key |
key_len | ref | rows | Extra |
+----+-------------+-------------+-------+---------------+---------+---------+------+------+------------------------------+
| 1 | SIMPLE | wp_postmeta | index | NULL | PRIMARY | 8
| NULL | 3472 | Using where; Using temporary |
+----+-------------+-------------+-------+---------------+---------+---------+------+------+------------------------------+
1 row in set, 1 warning (0.00 sec)
}}}
--
Ticket URL: <http://core.trac.wordpress.org/ticket/8561#comment:7>
WordPress Trac <http://trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list