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

Replace some AR calls to first with take #2889

Merged
merged 9 commits into from
Apr 15, 2019

Conversation

jmhooper
Copy link
Member

Why: Using #first adds a sort by pkey to the query which results in a slower query, in some cases daramtically slower. In situations where we don't care how the records are sorted we should use #take for better performance.

**Why**: Using `#first` adds a sort by pkey to the query which results in a slower query, in some cases daramtically slower. In situations where we don't care how the records are sorted we should use `#take` for better performance.
Copy link

@lauraGgit lauraGgit left a comment

Choose a reason for hiding this comment

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

Add something to issue template about take on ActiveRecord relations/ and possible in ruboCop

stevegsa
stevegsa previously approved these changes Apr 12, 2019
Copy link
Contributor

@stevegsa stevegsa left a comment

Choose a reason for hiding this comment

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

NICE!

@lauraGgit
Copy link

@jmhooper do you think that you'll be able to add a note on the PR template related to the take?

@jmhooper
Copy link
Member Author

@lauraGgit: I added a note to the "Database" section of the PR template

Copy link

@lauraGgit lauraGgit left a comment

Choose a reason for hiding this comment

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

LGTM! 🚀

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.

3 participants