Add a multi-column index on spree_reviews.approved + spree_reviews.product_id#158
Open
nzaillian wants to merge 1 commit intospree-contrib:masterfrom
Open
Add a multi-column index on spree_reviews.approved + spree_reviews.product_id#158nzaillian wants to merge 1 commit intospree-contrib:masterfrom
nzaillian wants to merge 1 commit intospree-contrib:masterfrom
Conversation
…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).
b9cdb5e to
0f3d283
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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...).