Skip to content

Use estimated_count instead of size on unfiltered criterias with Mongoid >= 7.2.0#13

Open
kalilz4485 wants to merge 1 commit into
kaminari:masterfrom
kalilz4485:mongoid-7.2-estimated-count
Open

Use estimated_count instead of size on unfiltered criterias with Mongoid >= 7.2.0#13
kalilz4485 wants to merge 1 commit into
kaminari:masterfrom
kalilz4485:mongoid-7.2-estimated-count

Conversation

@kalilz4485

Copy link
Copy Markdown

With mongoid 7.2.0 comes a change that may bring performances issue to kaminari

The .count method will really count documents when used without filters, instead of using the estimate count stored in the collection https://github.com/mongodb/mongoid/pull/4808/files

kaminari-mongoid uses size which is an alias for count, my approach is to override it to use estimate_count when we can

I didn't add any spec since it's not changing any expected result nor fixing anything

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant