[wp-hackers] Redundant queries?
alisencer at gmail.com
Tue Mar 29 14:56:41 GMT 2005
I am trying out WP1.5 and looking at the query-log of mysql for a
page-request that only displays a list of 10 entries. Some queries are
identical/duplicates, so the code could be easily rewritten to drop
these queries. This is only a suggestion. Maybe one of the devs that
is familiar with the WP codebase wants to look into this.
Here is a list of the queries as they are made during execution:
And here is a sorted list:
There are duplicates for:
SELECT * FROM wp_users WHERE ID = X
as well as for
SELECT COUNT(ID) FROM wp_posts WHERE 1=1 AND post_date_gmt <= 'X' AND
(post_status = "publish")
Not quiet duplicates, but possibly open for improvement concerning the
Category-queries. Currently there is one query like this:
SELECT DISTINCT ID, category_id, cat_name, category_nicename,
category_description, category_parent FROM wp_categories, wp_post2cat,
wp_posts WHERE category_id = cat_ID AND post_id = ID AND post_id IN
and an additional one for each post
SELECT category_id, cat_name, category_nicename, category_description,
category_parent FROM wp_categories, wp_post2cat WHERE
wp_post2cat.category_id = cat_ID AND wp_post2cat.post_id = 'X'
which is not really necessary, since it queries basically the same
information as the first one.
More information about the wp-hackers