spree_reviews icon indicating copy to clipboard operation
spree_reviews copied to clipboard

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

Open nzaillian opened this issue 7 years ago • 0 comments

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...).

nzaillian avatar Oct 04 '17 12:10 nzaillian