-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Optimize count query for pagination_total: false
option
#6911
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
`total_pages` is listed twice.
Queries like `SELECT COUNT(*) FROM (SELECT DISTINCT resources.* FROM resources ORDER BY resources.created_at DESC LIMIT 1 OFFSET 30) subquery_for_count` are too inefficient
d161507
to
fe0f95e
Compare
I updated the PR.
|
fe0f95e
to
f9b9f42
Compare
f9b9f42
to
948f71f
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #6911 +/- ##
=======================================
Coverage 99.11% 99.11%
=======================================
Files 141 141
Lines 4067 4069 +2
=======================================
+ Hits 4031 4033 +2
Misses 36 36 ☔ View full report in Codecov by Sentry. |
pagination_total: false
option
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! If I understand right, this is an optimization for when using the pagination_total: false
option? I've updated the PR title to reflect that for the release notes. Feel free to change if you think it can be improved as that's my only concern here. I think it would help to make any pagination query improvements we can so thank you for seeing this through.
* Remove duplicated delegation `total_pages` is listed twice. * Remove ORDER BY from count subquery Queries like `SELECT COUNT(*) FROM (SELECT DISTINCT resources.* FROM resources ORDER BY resources.created_at DESC LIMIT 1 OFFSET 30) subquery_for_count` are too inefficient * add specs about ensure count query does not include ORDER BY clause * exclude also select because based on https://github.com/activeadmin/activeadmin/pull/7489\#issuecomment-1554197081 --------- Co-authored-by: Rafael Sales <rafaelcds@gmail.com> Co-authored-by: David Rodríguez <deivid-rodriguez> Co-authored-by: Matias Grunberg <matias@yellowspot.dev>
* Remove duplicated delegation `total_pages` is listed twice. * Remove ORDER BY from count subquery Queries like `SELECT COUNT(*) FROM (SELECT DISTINCT resources.* FROM resources ORDER BY resources.created_at DESC LIMIT 1 OFFSET 30) subquery_for_count` are too inefficient * add specs about ensure count query does not include ORDER BY clause * exclude also select because based on https://github.com/activeadmin/activeadmin/pull/7489\#issuecomment-1554197081 --------- Co-authored-by: Rafael Sales <rafaelcds@gmail.com> Co-authored-by: David Rodríguez <deivid-rodriguez> Co-authored-by: Matias Grunberg <matias@yellowspot.dev>
* Optimize count query for `pagination_total: false` option (#6911) * Remove duplicated delegation `total_pages` is listed twice. * Remove ORDER BY from count subquery Queries like `SELECT COUNT(*) FROM (SELECT DISTINCT resources.* FROM resources ORDER BY resources.created_at DESC LIMIT 1 OFFSET 30) subquery_for_count` are too inefficient * add specs about ensure count query does not include ORDER BY clause * exclude also select because based on https://github.com/activeadmin/activeadmin/pull/7489\#issuecomment-1554197081 --------- Co-authored-by: Rafael Sales <rafaelcds@gmail.com> Co-authored-by: David Rodríguez <deivid-rodriguez> Co-authored-by: Matias Grunberg <matias@yellowspot.dev> * fix perform_database_query_matcher: make sure to keep match truthy after the first matched query --------- Co-authored-by: David Rodríguez <deivid.rodriguez@riseup.net> Co-authored-by: Rafael Sales <rafaelcds@gmail.com>
This is a rebased version of #5389.
Some of the changes proposed there have already been introduced, but there was some extra stuff that still seems useful. I guess this is lacking a spec, but seems ok to me other than that.