Need help with slow query
-
Hi,
I have this query running it runs allot and take a long time
SELECT wp_posts.* FROM wp_posts INNER JOIN wp_term_relationships ON (wp_posts.ID = wp_term_relationships.object_id) WHERE 1=1 AND ( wp_term_relationships.term_taxonomy_id IN (2,43,6,7,8,9,10,11,12,13,14,15,16,17,44,45,46,47,48,49,50,51,52,53) AND wp_posts.ID NOT IN ( SELECT object_id FROM wp_term_relationships WHERE term_taxonomy_id IN (18) ) ) AND wp_posts.post_type = 'post' AND (wp_posts.post_status = 'publish') GROUP BY wp_posts.ID ORDER BY wp_posts.post_date DESC LIMIT 0, 40\GFrom what i understand it is generated by wp-blog-header.php
This is what I got from slow query log:
# Query 1: 0.02 QPS, 0.65x concurrency, ID 0xA13A8CDCEEA90AEA at byte 244013 # Scores: Apdex = 0.14 [1.0], V/M = 48.37 # Query_time sparkline: | _^| # Time range: 2012-04-30 14:40:37 to 2012-05-01 14:30:02 # Attribute pct total min max avg 95% stddev median # ============ === ======= ======= ======= ======= ======= ======= ======= # Count 36 1296 # Exec time 73 55923s 1s 249s 43s 107s 46s 17s # Lock time 55 5167s 0 212s 4s 6s 25s 0 # Rows sent 44 49.11k 3 40 38.80 38.53 6.31 38.53 # Rows examine 47 54.33M 34.60k 51.62k 42.93k 51.46k 8.31k 34.83k # Query size 49 597.58k 440 506 472.16 487.09 33 420.77 # String: # Databases ***** # Hosts ***** # Users ***** # Query_time distribution # 1us # 10us # 100us # 1ms # 10ms # 100ms # 1s ########################################################## # 10s+ ################################################################ # Tables # SHOW TABLE STATUS FROM <code>MY-DB-NAME</code> LIKE 'wp_posts'\G # SHOW CREATE TABLE <code>MY-DB-NAME</code>.<code>wp_posts</code>\G # SHOW TABLE STATUS FROM <code>MY-DB-NAME</code> LIKE 'wp_term_relationships'\G # SHOW CREATE TABLE <code>MY-DB-NAME</code>.<code>wp_term_relationships</code>\G # EXPLAIN /*!50100 PARTITIONS*/ SELECT wp_posts.* FROM wp_posts INNER JOIN wp_term_relationships ON (wp_posts.ID = wp_term_relationships.object_id) WHERE 1=1 AND ( wp_term_relationships.term_taxonomy_id IN (2,43,6,7,8,9,10,11,12,13,14,15,16,17,44,45,46,47,48,49,50,51,52,53) AND wp_posts.ID NOT IN ( SELECT object_id FROM wp_term_relationships WHERE term_taxonomy_id IN (18) ) ) AND wp_posts.post_type = 'post' AND (wp_posts.post_status = 'publish') GROUP BY wp_posts.ID ORDER BY wp_posts.post_date DESC LIMIT 0, 40\GI’m new to all this, can anyone explane me what exactly this query does and how can I improve it.
Thanks
G.
The topic ‘Need help with slow query’ is closed to new replies.