The use of SQL_CALC_FOUND_ROWS
is not really a problem, although it incurs an overhead.
What happens is, WordPress uses SQL_CALC_FOUND_ROWS
in order to determine the total posts that would have been returned, if no LIMIT
clause was provided. This is necessary in order to calculate and provide you with correct pagination links.
Disabling it unconditionally is guaranteed to break things all over the place.
If you can identify specific queries that suffer from its use, and you can do without pagination, then you could hook to pre_get_posts
and conditionally set the no_found_rows
parameter to true.
This, however, is more a hack than a solution.
The proper solution is to use a database query caching mechanism, either on the side of the database, or on the WordPress side using a plugin such as Advanced Post Cache (developed for and used in WordPress.com)
Related Posts:
- Should I use Transients with W3 Total Cache APC Caching? [closed]
- Get posts by menu ID
- Stop all SQL_CALC_FOUND_ROWS wordpress queries
- WP_Query Performance Issues with meta_query
- Improve wp query perfomance on large db
- Order by custom table and multiplication
- Single meta_query query using OR instead of AND in request’s WHERE statement
- why update and delete query not worked in custom table?
- How to implement a new row_count method in WordPress?
- Which is faster wpdb & get_row or wp_query & ge_post_meta?
- how to get Nearby zipcode
- How I can change the condition or compare operator for WP_Query in pre_get_posts
- WP_Query with page_ids in arguments without a result
- Why last row deleted when refresh page
- Fix wp_term_relationships slow query in get_posts
- update_post_meta performance in a loop woocommerce
- update_post_meta performance in a loop woocommerce
- WP_Term_Query->get_terms() very slow query for WordPress filter
- Website goes slow down after importing long database
- WP_Query always returning the last custom post
- Optimising amount of calls to custom fields
- SQL query into to WP query
- When to use WP_query(), query_posts() and pre_get_posts
- Should I use Pre Get Posts or WP_Query
- Using pre_get_posts with WP_Query
- Ignoring initial articles (like ‘a’, ‘an’ or ‘the’) when sorting queries?
- Return only Count from a wp_query request?
- Use REGEXP in WP_Query meta_query key
- WP_Query orderby post__in remains ineffective in the Loop [closed]
- What is “main query”? [duplicate]
- Order by DESC, ASC in custom WP_Query
- How to prevent execution of default query, while preserving ability to use WP_Query in template?
- WordPress database scalability from the code perspective
- Reduce or prevent calling of update_meta_cache
- How to add taxonomy filter on the query fly?
- Changing the meta_query of the main query based on custom query_vars and using pre_get_posts
- Differences Between WP_Query() and get_posts() for Querying Posts?
- How to uniquely identify queries?
- What is the most efficient way of querying posts based on visits and date for current day?
- Add indexing to meta_value in wp_postmeta
- Order Search Results Page by meta_value If no Value Return Remaining Results
- Getting wrong relationship value in $args in wp_Query?
- find a random blogid across my multisite network that has at least one post published
- pre_get_posts with get_posts
- Is it true $wpdb->get_results is faster than WP_Query in most cases?
- How-to exclude terms from the main query the most performant way?
- Changing Posts Per Page and offset with pre_get_posts
- “pre_get_posts” firing on every query
- RSS feed with specific keyword
- WordPress for a very large website
- Using is_main_query to select custom post type on certain page
- get_the_title($postID) OR get_the_title()?
- Multiple orderby parameters in pre_get_posts() action
- WooCommerce with thousands of products – site is very slow – optimize db queries? [closed]
- SQL Statement generated by WP_Query not producing expected results
- What is an efficient way to query based on post_meta?
- SQL query equivalent to WP User Query
- What’s wrong with this WP query?
- How to count post meta key values for all posts in database
- Sorting Posts by custom field
- How to pass custom parameter to WP_Query for filtering in pre_get_posts
- Query with pre_get_posts to get pagination
- Group posts by meta_key
- Recommended way to drop a pending query (in pre_get_posts)?
- How to search for posts IN OR title OR content OR author?
- How to solve slow WordPress site caused by attachment_metadata
- Single page theme that uses pages for the content
- WP_Query hit max joins… How else can I build a search function that uses custom fields?
- WordPress custom search form with pre_get_posts not work
- Would this post meta be better added to the post table rather than post_meta table
- If orderby parameter using pre_get_posts is the same for multiple posts what fallback does the query use?
- Can not switch the queried post in pre_get_posts hook
- Slow speed and high CPU usage for my code. How to improve it?
- Multiple queries on Home Page – page load/site speed issue
- How to target the default Recent Posts and Recent Comments widgets with pre_get_posts?
- How to find if a post with custom_field == X exists?
- order by multiple meta keys in pre_get_posts
- Order By Multiple Meta Fields
- meta_query on a date range using an array of values
- Changing BIGINT to INT
- if statement on database query
- Should close $wpdb via $wpdb->close()
- How to speed up wp_query, took more 5s to run against 100k posts
- How to sort posts in admin by titles with dd.mm.yyyy format?
- Get the post permalink within the loop but without additional DB query
- WP_Tax_Query with post_tag not working
- Filter WordPress posts by between parameter
- Splitting the main query in multiple loops with query_posts and/or pre_get_posts?
- Database slowdown after update to 3.4.1
- SQL User Query by Multiple Roles using PHP
- How to Modify Taxonomy Archive Page with Search Parameter?
- Using pre_get_posts on a specific core/query block
- Retrieve featured image (thumbnail) url from multiple posts with one query
- WordPress Query is taking more then 20 second and stuck on creating index
- Searching through different categories on different pages code is not working
- How to display future posts – modified query still yields 404
- Too many posts cause slow load when paginating
- Get the Plugin Which Triggered a MySql Query in WordPress?
- pre_get_posts filter meta_query without conflicting existing meta_query
- Including only current user’s posts in search