[wp-hackers] get_permalink() creates huge amounts of db access with plugins

denis at semiologic.com denis at semiologic.com
Wed Apr 13 14:41:52 GMT 2005


Weee, thanks a lot! Two dozen queries got their heads chopped off!

Btw, you might want to check (or change) the workflow. Through trials and errors
using SAVEQUERIES, I found a call to get_permalink queries the DB twice per
post. To reproduce this, try:

http://www.semiologic.com/projects/recent-updates/

and comment out the two lines where I cache the posts.

A temporary fix I came up with was to call both update_post_cache() and
update_page_cache(), but this is obviously not the right thing to do. Maybe
update_page_cache could be a mere alias for update_post_cache.

D.


Quoting Ryan Boren <ryan at boren.nu>:

> On Wed, 2005-04-13 at 00:07 +0000, denis at semiologic.com wrote:
> > hello,
> >
> > while programing a couple of plugins, i've been using things such as:
> >
> > apply_filters('the_permalink', get_permalink($cur_post->ID));
> > apply_filters('the_permalink', get_category_link($cur_cat->cat_ID) );
> >
> > it initially occured to me it would be nice to use them rather than hard
> coding
> > the permalinks.
> >
> > but only initially. i eventually found myself wondering how a silly blog
> page
> > could require 40+ queries...
>
> Is this with 1.5.1?  The caching has been changed a bit in 1.5.1.  You
> shouldn't see multiple queries, especially not with categories since we
> query all categories up front.  You might see multiple queries if your
> plugin is pulling in posts that are not part of the main query.  The
> plugin can use update_post_caches() or update_post_cache() to avoid
> multiple queries.
>
> Ryan
>
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>




----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.


More information about the wp-hackers mailing list