[wp-hackers] get_userdata and _fill_user causing huge number of database queries

Dion Hulse (dd32) wordpress at dd32.id.au
Thu Mar 4 08:28:07 UTC 2010


On Thu, 04 Mar 2010 09:50:40 +1100, Simon B <piemanek at gmail.com> wrote:
> I've set up a test page as follows:
  <snip>
> For every post returned, those two db queries (get_userdata and  
> _fill_user)
> are taking place. From the debug output it looks to me that it's  
> the_post()
> that is calling them:

Yes, Every time a post is displayed, the Author data is retrieved, which  
results in those queries, So if you query for ALL posts, you'll query for  
ALL users as well.

The test script is really the worst case scenario, I was under the  
impression you were seeing those 101 queries on the home page/blog page.

Whilst i havnt looked into trunk's user caching changed of late yet, It  
makes sense to mass-load/cache the user data in one swipe on get_posts  
where multiple authors are concerned.
-- 
Dion Hulse / dd32

Contact:
  e: contact at dd32.id.au
  msn: msn at d32.id.au
  skype: theonly_dd32
  Web: http://dd32.id.au/


More information about the wp-hackers mailing list