Fix pagination_total index option to prevent SELECT COUNT queries#5388
Closed
rafaelsales wants to merge 1 commit intoactiveadmin:masterfrom
Closed
Fix pagination_total index option to prevent SELECT COUNT queries#5388rafaelsales wants to merge 1 commit intoactiveadmin:masterfrom
rafaelsales wants to merge 1 commit intoactiveadmin:masterfrom
Conversation
rafaelsales
commented
Apr 3, 2018
| paginated_collection(collection, pagination_total: false) | ||
| ActiveRecord::Base.logger = nil | ||
| expect(log.string).to_not include 'SELECT COUNT' | ||
| end |
Contributor
Author
There was a problem hiding this comment.
Since the fix is not implemented yet, this spec fails:
1) ActiveAdmin::Views::PaginatedCollection creating with the dsl with :pagination_total set to false should not perform count queries
Failure/Error: end
expected "D, [2018-04-02T22:48:21.957729 #82970] DEBUG -- : \e[1m\e[35m (0.2ms)\e[0m \e[1m\e[34mSELECT COUN...T 1 FROM \"posts\" LIMIT ? OFFSET ?) subquery_for_count\e[0m [[\"LIMIT\", 30], [\"OFFSET\", 0]]\n" not to include "SELECT COUNT"
and the log output shows the count queries:
D, [2018-04-02T22:48:21.957729 #82970] DEBUG -- : (0.2ms) SELECT COUNT(*) FROM (SELECT 1 FROM "posts" LIMIT ? OFFSET ?) subquery_for_count [["LIMIT", 1], ["OFFSET", 0]]
D, [2018-04-02T22:48:22.172004 #82970] DEBUG -- : (0.2ms) SELECT COUNT(*) FROM (SELECT 1 FROM "posts" LIMIT ? OFFSET ?) subquery_for_count [["LIMIT", 30], ["OFFSET", 0]]
D, [2018-04-02T22:48:22.172614 #82970] DEBUG -- : Post Load (0.1ms) SELECT "posts".* FROM "posts" ORDER BY "posts"."id" ASC LIMIT ? OFFSET ? [["LIMIT", 1], ["OFFSET", 0]]
D, [2018-04-02T22:48:22.175192 #82970] DEBUG -- : (0.1ms) SELECT COUNT(*) FROM (SELECT 1 FROM "posts" LIMIT ? OFFSET ?) subquery_for_count [["LIMIT", 30], ["OFFSET", 0]]
D, [2018-04-02T22:48:22.175794 #82970] DEBUG -- : (0.1ms) SELECT COUNT(*) FROM (SELECT 1 FROM "posts" LIMIT ? OFFSET ?) subquery_for_count [["LIMIT", 30], ["OFFSET", 0]]
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The PR #3848 was supposed to make sure that
paginate_total: falseoption preventsSELECT COUNTqueries. Unfortunately, the current AA version (v1.2.1) makes count queries whenpaginate_total: falseis provided.The goal of this PR is to add a spec to assert on the count query and fix the issue.