For some code refinement and to add new features to my plugin, I want to display posts ordered by specific meta column value like this;
query_posts($query_string . '&meta_key=views&orderby=meta_value&order=DESC');
Can it cause performance issue for big blogs having total post more than 10000+?
- I can use WP_Query() or get_posts() in place of query_post()
meta_query & tax_query behavior
When you’re defining a
meta/tax_query
and make use of the new array style argument list for multiple sets of term or custom field keys, then your query might look close to the followingThis would be the result:
Example code taken from this trac ticket by @Otto. Please subscribe there to follow its progress and vote for getting a change into core.
The problem with the query …
… basically is that you’ll get a
JOIN
for every column. It’s not necessary, as the tables are already melted together with the 1stJOIN
. Sadly core simply behaves like that at the current state 3.3.x and will stay like this in 3.4.Maybe a solution?
Your best chance would be to intercept the
posts_clauses
filter in your plugin and manually change the query. The real problem with this solution is that you’d have to do astr_replace( $search, $replace, $query );
in your plugin. On the one hand, that’s maybe slowing things down and on the other hand you’d have to follow this ticket as when this moves in, your plugin will simply break (better leave a link to the ticket in your plugins code).What can I do?
Jump into trac and add your thoughts & patches to the ticket. If you’re a real hero, then you could try to get at the
meta_query
problem too.Community would thank you 🙂
If you think this img is inappropriate, just delete it.