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

Fix N + 1 for Refinery::Blog::Post.live #502

Open
lanzhiheng opened this issue Jan 13, 2019 · 5 comments
Open

Fix N + 1 for Refinery::Blog::Post.live #502

lanzhiheng opened this issue Jan 13, 2019 · 5 comments

Comments

@lanzhiheng
Copy link

Version: refinerycms-blog (4.0.0)

I encounter the N + 1 query when using Refinery::Blog::Post.live

image

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

image

@bricesanchez
Copy link
Member

Hi @lanzhiheng ! Could you provide a pull request?

@lanzhiheng
Copy link
Author

lanzhiheng commented Jan 14, 2019

@bricesanchez I am sorry that I forgot, I will provide a pull request later. 😢

@lanzhiheng
Copy link
Author

@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

image

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?

@parndt
Copy link
Member

parndt commented Jan 19, 2019

Normally I expect joins to produce only a single query; what's the peformance difference you're seeing?

@lanzhiheng
Copy link
Author

@parndt

image

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

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

No branches or pull requests

3 participants