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

Missing index on merit_actions table for processed #355

Closed
adrienpoly opened this issue Apr 9, 2021 · 2 comments · Fixed by #356
Closed

Missing index on merit_actions table for processed #355

adrienpoly opened this issue Apr 9, 2021 · 2 comments · Fixed by #356

Comments

@adrienpoly
Copy link
Contributor

adrienpoly commented Apr 9, 2021

I have been noticing some slow queries on Merit::Action find. Finds where in the range of 100ms whereas most of the simple queries would be in the range of a few ms.

The exact query is:

SELECT  "merit_actions".* FROM "merit_actions" WHERE "merit_actions"."processed" = $? ORDER BY "merit_actions"."id" ASC LIMIT $? 

After adding an index to the column processed the query time dropped drastically to an average 2ms

Capture d’écran 2021-04-09 à 6 12 22 AM

Shouldn't this index be added by default during the install? Or should it simply be documented somewhere?

Thanks for this great gem

@tute
Copy link
Member

tute commented Apr 9, 2021

Yes, it should! Thanks for your report. Do you want to send a PR adding the index to that migration's template? So new installations will carry it.

(I wouldn't take care of preexisting installations, as adding an index to a big table can be time consuming, and the developer should do it with care.)

@adrienpoly
Copy link
Contributor Author

ok will send a PR shortly

@tute tute closed this as completed in #356 Apr 9, 2021
tute pushed a commit that referenced this issue Apr 9, 2021
* add index to migration template
* add index to dummy app

[closes #355]
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 a pull request may close this issue.

2 participants