refinerycms-blog
refinerycms-blog copied to clipboard
Fix N + 1 for Refinery::Blog::Post.live
Version: refinerycms-blog (4.0.0)
I encounter the N + 1 query when using Refinery::Blog::Post.live

Look's good if using Refinery::Blog::Post.includes(:translations).live

Hi @lanzhiheng ! Could you provide a pull request?
@bricesanchez I am sorry that I forgot, I will provide a pull request later. 😢
@bricesanchez Each post's record will need the translation data. so If I avoid the N + 1 query by using includes It will cause a very long query statement. like below

I think It is so hard to review by developer. May be the N + 1 version (just using joins) is better than this. I am not sure should I change it to includes? Can you give me some advices?
Normally I expect joins to produce only a single query; what's the peformance difference you're seeing?
@parndt

I am not very sure which is better. In my opinion, I expect joins too. 😿 Can you discuss it with @bricesanchez .