Skip to content
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

fix: associations query limit on select options #3418

Merged
merged 7 commits into from
Nov 18, 2024

Conversation

thiagoyoussef
Copy link
Contributor

@thiagoyoussef thiagoyoussef commented Nov 13, 2024

Description

Fixes #2406

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works

Screenshots & recording

On attach model:
CleanShot 2024-11-13 at 15 13 56@2x

On edit belongs to:
CleanShot 2024-11-13 at 15 17 32@2x

@github-actions github-actions bot added the Fix label Nov 13, 2024
@thiagoyoussef thiagoyoussef force-pushed the fix/associations-query-limit branch from ef95dc6 to 3cd8add Compare November 13, 2024 18:16
Copy link

codeclimate bot commented Nov 13, 2024

Code Climate has analyzed commit bba4886 and detected 0 issues on this pull request.

View more on Code Climate.

Copy link
Contributor

@Paul-Bob Paul-Bob left a comment

Choose a reason for hiding this comment

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

The query.all.count will perform sub-optimal on large datasets

From this stackoverflow thread:

I just ran into a situation where a table of 1.3 million rows was taking about 35 seconds to perform a simple SELECT COUNT(*).

For our table with 20M records, it took 4 minutes.

Instead, I suggest fetching records with the defined limit, then checking the size of the retrieved dataset. If the result size matches the limit, two scenarios are likely:

  • There are more records beyond the limit (most probable).
  • The limit precisely matches the total record count (less less less probable).

Let's discuss the option name and the default limit.

Otherwise this PR looks good! Thank you @thiagoyoussef

@thiagoyoussef thiagoyoussef force-pushed the fix/associations-query-limit branch from 5b21720 to f989d91 Compare November 14, 2024 10:42
@Paul-Bob Paul-Bob merged commit fb2e2a8 into avo-hq:main Nov 18, 2024
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Prevent memory bloat in associations when searchable is set to false
2 participants