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

Jeremy Clarke jer at simianuprising.com
Thu Mar 4 15:52:17 UTC 2010


I have found this to be a really big problem overall, all those database
queries are a nightmare. I'm no MySQL expert, but I feel like if you're
likely to have more than 20 users 'displayed' on a given page (say you have
a sidebar widget that shows a twitter-style avatar list) then you're
probably better off loading every single user with one query at the start of
pageload (so that they get cached) rather than loading each one as they come
up.

For such features I've resorted to caching all user information in a
wp_options field and using that data in my widgets (which is annoying but
has other benefits like the potential to add properties to the user objects
and expect them in my cache).

FWIW, this is another reason why a proper get_users() system is needed. It
would be great if we could say at the start of a page
get_users('cap=edit_posts'), effectively loading and caching all users who
are liable to show up in the UI with one query.

-- 
Jeremy Clarke | http://jeremyclarke.org
Code and Design | http://globalvoicesonline.org


More information about the wp-hackers mailing list