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
- Meta_query compare operator explanation
- meta_query ‘compare’ => ‘IN’ not working
- Ignoring initial articles (like ‘a’, ‘an’ or ‘the’) when sorting queries?
- Sorting: custom query with orderby meta_value_num THEN by title
- Using OR conditions in meta_query for query_posts argument
- WP_Query with checkbox meta_query
- Get posts by menu ID
- Meta Query with date and time on the same Day before given time
- How to grab metabox value in wp_query meta_query key
- How to count post meta key values for all posts in database
- WP Query – Get WooCommerce Products with variation that is in stock
- Meta_query with or without value
- Exporting Data from WordPress into a flat table
- wp_query not searching with apostrophe
- $wpdb select date range of posts
- Custom query based on meta key – Reduce three states to two in results?
- Query that loads a custom type AND posts whose ids are not inside those custom types custom fields
- How to display multiple custom fields with the same meta_key in an ascending order?
- Meta_query with multiple keys and multiple values
- Tax query AND/OR meta query [duplicate]
- How do I query for posts by partial meta key?
- Help ordering Post loop by two meta values
- No results found from a $wpdb->get_results() query when trying to join more than one meta key query
- How to increase load time of an archive/search page (WP_Query)
- Hide posts with meta key in WP_Query
- Appending to existing WP_Query’s meta_query if exists
- Custom query filter by ACF date custom field
- Error in meta_query not get result
- How to get current page nearest parent id?
- meta_query – check for multiple meta values in key which holds an array of values
- Searching for a specific month in a metadata saved as Timestamp (Wp_Query)
- How to get meta key list efficiently?
- WP_Query on custom key and value
- Get posts having meta value between two numbers
- Query by meta value (add a dropdown of all values)
- Separate by Category Post Type
- Calculating efficiently on large amount of data generated by wp_query
- WP_Query returns empty if meta_query has more than 7 values
- WordPress meta_query not working
- Using orderby with 2 meta keys
- How to get several fields from wp_query?
- query by meta value then date and not empty meta value
- How do I have multiple metaqueries inside one wordpress query