Skip to content

Backport Optimize count query for pagination_total: false option#8470

Merged
mgrunberg merged 3 commits into3-0-stablefrom
backport-6911
Sep 4, 2024
Merged

Backport Optimize count query for pagination_total: false option#8470
mgrunberg merged 3 commits into3-0-stablefrom
backport-6911

Conversation

@mgrunberg
Copy link
Contributor

Backport #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>
@codecov
Copy link

codecov bot commented Sep 4, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Please upload report for BASE (3-0-stable@276b0d4). Learn more about missing BASE report.

Additional details and impacted files
@@              Coverage Diff              @@
##             3-0-stable    #8470   +/-   ##
=============================================
  Coverage              ?   99.19%           
=============================================
  Files                 ?      194           
  Lines                 ?     4965           
  Branches              ?        0           
=============================================
  Hits                  ?     4925           
  Misses                ?       40           
  Partials              ?        0           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@javierjulio javierjulio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@mgrunberg mgrunberg enabled auto-merge (squash) September 4, 2024 14:54
@mgrunberg mgrunberg merged commit c0cff8f into 3-0-stable Sep 4, 2024
@mgrunberg mgrunberg deleted the backport-6911 branch September 4, 2024 15:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants