I’d like to see what the actual generated SQL is that WP_Query
is using, but for now.
( You can use http://wordpress.org/extend/plugins/debug-bar/ to easily view the SQL query )
Queries ordered by ‘random’ are inefficient. If you don’t need that remove it. If you do need a random order, consider removing it anyway and using PHP’s shuffle
to randomize.
LIKE
queries are also fairly inefficient. Use =
if you can.
You might be faster to write a query of your own that pulls the post IDs out of the postmeta table and then use WP_Query
with a simple post__in
parameter to pull post content. This may or may not help, but is worth the experiment.
Related Posts:
- WP_Query by meta key not returning any posts
- Use REGEXP in WP_Query meta_query key
- Add indexing to meta_value in wp_postmeta
- Getting attachments by meta value
- WP_Query not working as expected for attachments and custom meta_query
- How can I create a WP_Query that returns posts where one meta_value
- WordPress altering my custom query, How to fix it?
- WP Meta Query for some meta (array) values
- How to get sum of meta_values of a meta_key in wp_query according to conditions
- Filter WordPress posts by between parameter
- Advanced WP Query hogs the SQL server
- Order posts by meta value and Date
- How To Get Some Data From WordPress Database Using WordPress $wpdb Query?
- Query post with meta_query where date is not in future
- Get meta info related to current post
- Select from wp_post and multiple meta_value from wp_postmeta
- SQL: What is wrong with the following query (generated by WordPress WP_Query, ordering prices)
- How to make Meta Query case sensitive?
- Performance when getting post meta for post retrieved by meta value
- Get attachment by meta_key value
- Optional Meta Query
- Fetch Record based on meta key dates
- how to make members list directory through wordpress post custom meta key.
- Changing sort order for presentation by Jetpack infinite scroll
- Large AND OR query timing out
- database query with more than a couple meta hangs and doesn’t complete
- Is it possible to query from external database? [duplicate]
- Filter posts by comparing custom meta value against postdate
- List of ways to access WordPress database?
- How to set up hierarchical relationships without using plugins / meta query
- Slow Query On Search
- WP_Query: apply an SQL function to meta fileld value
- Nested array issue in meta_query
- Query posts by searching for a string in a meta field
- WP_Query meta compare must include ALL array values
- How do i create a custom post query when the meta value is an array?
- wp query to use both author id and meta_query
- WP Query – grouping posts by same meta key, adding together values from another key
- Meta query ignores multiple values of the key
- Trouble with serialized metadata
- show most viewed post
- Why can my filter query SOME metadata but not other metadata?
- Query against multiple locations within single custom post type post
- Translating WP query into to SQL query
- update_post_meta performance in a loop woocommerce
- update_post_meta performance in a loop woocommerce
- How to set meta_query if get_post_meta returns nested array for that key? [duplicate]
- Slow wp_posts and wp_postmeta query using Advance Custom Fields
- Saving custom fields for WP_Query to retrieve
- How to show all the associated posts with specific date of data metabox?
- WP Meta Query at depth 2
- Include post_status check within $wpdb query
- WP_Query Posts by Metadata from Option Tree
- WP Query to order posts by multiple meta fields
- Return a single custom post from multiple meta queries
- WP_Query with several meta_query-statements and order by meta_value
- 294 Queries on Mainpage of WordPress
- Is it possible to query a custom field where the value is between two fields?
- Meta Query doesn’t works as espected
- Include post content of linked posts in search
- WP User Query with Custom Fields and Search Results
- Make a SQL query with wpdb in WordPress
- Getting additional columns from sql
- WordPress query posts with multiple post_meta data
- How to provide meta_key array to wp_query?
- Wp_query with 2 meta keys and array of meta values
- Advanced WP_Query with meta_query, orderby?
- meta_query: check if number exists
- WP_Query – Accessing MetaValue from Query Result
- Searching for meta_key returns 0 posts
- Event with multiple dates, display events chronologically
- Specify strict ‘order by’ in WordPress query
- meta_query fails to compare on values containing apostrophes
- meta queries do ‘either/or’ checks
- search serialised meta_value for date value?
- How do I check if an article is popular this week?
- WP Query ordering on a meta field for posts with a date in the future not ordering by datetime
- how to get Nearby zipcode
- Getting rid of unwanted nonSQL syntax characters when debugging a query
- Is this meta query problematic?
- How I can change the condition or compare operator for WP_Query in pre_get_posts
- WP Query Meta Value – How To Identify Specific, Unique Values?
- Does WordPress have something like Drupal’s DB API?
- Selecting posts with a given meta value for a meta key
- Order by meta_key doesn’t work
- WP_Query of custom post type sorted by meta_key has unexpected results
- Using Transients
- Check if searched number is within the post meta value
- Meta query compare for ID’s greater than specific ID
- Appending to existing WP_Query’s meta_query if exists
- Query where ANDing slug values not working
- Issues with search after added meta_query
- Sort by presence of thumbnail
- Display posts with specific value first in query
- Get every post with value in meta key
- it’s possible make a WP_Query with math operations?
- Multiple meta_key ordering with pre_get_posts
- how to write wordpress query for multiple metakeys checking?
- Sorting search results with custom dropdown
- get_page meta query not working, maybe a bug?