[wp-hackers] Seeking SQL advice to identify performance problem

Mike Walsh mpwalsh8 at gmail.com
Fri Jun 22 18:58:27 UTC 2012


On Wed, Jun 20, 2012 at 5:38 PM, scribu <mail at scribu.net> wrote:

> On Wed, Jun 20, 2012 at 4:52 PM, Simon Blackbourn <piemanek at gmail.com
> >wrote:
>
> > You can use the get_users() function [1] with the 'fields' parameter set
> > to 'all_with_meta', and then perform a usort on the results:
> >
> > $args = array(
> > 'number'     => 1000000, //  unfortunately you can't use -1 here
> > 'fields'     => 'all_with_meta', // required
> >                        'exclude' => array( 1 ) // user IDs to exclude
> > );
> >
> > $user_list = get_users( $args );
> >
>
> Actually, unlike WP_Query, users are not paginated by default, so if you
> don't pass the 'number' parameter at all, you'll get all the users.
>
> As for the "magic" that Otto mentioned, here's a blog post about it:
> http://scribu.net/wordpress/the-magic-of-wp_user.html
>
>
>
Now that I understand the magic, and the link to the post helped a lot,
this makes more sense and I am using it place of the SQL for one part of my
plugin.  I've tried to migrate it to a second instance and as near as I can
tell, I cannot order the results of get_users() on a user meta value.  Am I
correct or as in the earlier case, am I missing something?

Thanks,

Mike
-- 
Mike Walsh - mpwalsh8 at gmail.com


More information about the wp-hackers mailing list