Opened 9 years ago
Last modified 9 years ago
#42256 new defect (bug)
Skip SQL_CALC_FOUND_ROWS when using post__in whose count matches posts_per_page
| Reported by: | ethitter | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | Awaiting Review |
| Component: | Query | Version: | |
| Severity: | normal | Keywords: | reporter-feedback |
| Cc: | Focuses: |
Description
If a post__in array is passed to WP_Query whose length matches the posts_per_page value for the query, SQL_CALC_FOUND_ROWS is unnecessary.
Attachments (2)
Change History (5)
#2
@
9 years ago
What if the values in post__in point to non-existent posts? Or, perhaps more likely, what if the combination of post__in with some other param (say, a meta_query) makes it so that only a subset of the post__in items are grabbed?
It feels safer to let plugins decide whether they're passing query parameters that guarantee that all and only the items in post__in will end up in the results array. If the plugin knows this, it can pass no_found_rows explicitly.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
42256.2.diff adds a test.