Skip to content

Instantly share code, notes, and snippets.

@kovshenin kovshenin/one.sql
Created Sep 28, 2011

Embed
What would you like to do?
SQL Query
mysql> explain SELECT SQL_CALC_FOUND_ROWS wp_posts.post_title FROM wp_posts INNER JOIN wp_postmeta ON (wp_posts.ID = wp_postmeta.post_id) WHERE 1=1 AND wp_posts.post_type = 'post' AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'private') AND ( (wp_postmeta.meta_key = 'my-field' AND CONVERT(wp_postmeta.meta_value, CHAR) = 'some value') ) GROUP BY wp_posts.ID ORDER BY wp_posts.post_date DESC LIMIT 0, 10;
+----+-------------+-------------+--------+---------------------------------+----------+---------+---------------------------+------+----------------------------------------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+-------------+--------+---------------------------------+----------+---------+---------------------------+------+----------------------------------------------+
| 1 | SIMPLE | wp_postmeta | ref | post_id,meta_key,meta_key_value | meta_key | 768 | const | 3 | Using where; Using temporary; Using filesort |
| 1 | SIMPLE | wp_posts | eq_ref | PRIMARY,type_status_date | PRIMARY | 8 | wp_32.wp_postmeta.post_id | 1 | Using where |
+----+-------------+-------------+--------+---------------------------------+----------+---------+---------------------------+------+----------------------------------------------+
2 rows in set (0.00 sec)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.