[wp-hackers] Redundant queries?
Sencer
alisencer at gmail.com
Tue Mar 29 14:56:41 GMT 2005
Hello,
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:
http://www.sencer.de/code/wp/qlog.txt
And here is a sorted list:
http://www.sencer.de/code/wp/qsort.txt
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
(1352,1351,1350,1349,1348,1347,1346,1345,1344,1343)
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.
Regards
Sencer
--
http://www.sencer.de
More information about the wp-hackers
mailing list