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: When using SelectPlus with a relationship in index, it creates a N+1 problem. #70

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

HenriqueSPin
Copy link

This pull request prevents redundant database queries when displaying SelectPlus in index fields. Currently, an extra query is executed per line due to repeated loading of relationships, even when eager loading is utilized with $with. This update ensures that relationships are only loaded if they have not been previously loaded, optimizing performance.

Check if the relation is already loaded to prevent redundant loading.
@HenriqueSPin
Copy link
Author

Hello, @ralphschindler ! Can you please take a look at this? Many thanks for considering my request.

@ralphschindler
Copy link
Member

Hi! I was looking at this last week, is there a reason you closed?

@HenriqueSPin
Copy link
Author

HenriqueSPin commented Aug 7, 2024

I thought that it was going nowhere. I can reopen it if it will be considered. Should I?

@HenriqueSPin HenriqueSPin reopened this Aug 7, 2024
@HenriqueSPin
Copy link
Author

@ralphschindler Here it is.
I will open another PR with a fix that properly emits the attribute-x-change event on the event bus, so we can have fields depending on this field.

@HenriqueSPin
Copy link
Author

@ralphschindler Is there something missing? Do you need more context?

@gustavocaiano
Copy link

@ralphschindler please take a look, also waiting on this.

@ralphschindler
Copy link
Member

ralphschindler commented Aug 13, 2024

Hi @HenriqueSPin,

I opened the demo app included, and attempted to replicated the problem (I also added laravel-debugbar to view queries. How can I see the problem you're reporting? What steps do I take? I assume I should be looking at the statesVisited relation on the Person model?

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.

3 participants