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

Add a multi-column index on spree_reviews.approved + spree_reviews.product_id #158

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

nzaillian
Copy link

@nzaillian nzaillian commented Oct 4, 2017

Index these columns as they are used for scoping records in the stock gem controllers (and likely used in any custom controllers users are likely to write as well).

Context: in our application we have 10s of ks of reviews across ~60 products. We've discovered that these columns are unindexed and there is at this size a big performance consequence (like ~60ms+ in a pretty well-provisioned Postgres db). It seems the compound index is the one that's most performant. If you think it makes sense to additionally add a single-column index on product_id I can do this as well (I think the multi-column supports the query on only approved = ? so I don't think there needs to be an additional index on approved, but I don't think it supports a query on product_id only - but you're not likely to be making such a query in a frontend I don't think...).

…oduct_id

Index these columns as they are used for scoping records
in the stock gem controllers (and likely used in any
custom controllers users are likely to write as well).
@nzaillian nzaillian force-pushed the index-product-id-and-approved branch from b9cdb5e to 0f3d283 Compare October 4, 2017 12:59
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