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

Query in getModelsPerType() only by ids #1

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

Conversation

netzknecht
Copy link

There is no need to use other query conditions (e.g. local and global scopes) here again, because they are already present in the query in the "getIdAndOrderAttributes()"-method. So, it's sufficient enough to load the models by id.

I've recently posted that pull request at protonemedia/laravel-cross-eloquent-search, but that one is closed because I had to delete the forked head repository, to switch to a fork of your fork artkonekt/search.

@fulopattila122
Copy link

Hello, and sorry for the slow reaction.

Please apply the StyleCI patch https://github.styleci.io/analyses/o7kl0P and push the changes to the PR.

Also, could you tell me what the goal of the change is? What will be different after merging this PR?

@fulopattila122 fulopattila122 self-assigned this Nov 13, 2023
@fulopattila122 fulopattila122 added the enhancement New feature or request label Nov 13, 2023
@fulopattila122
Copy link

Unfortunately, the changes (as of now) break the eager load functionalities, which can result in a significant performance penalty:

image

see the test run

@netzknecht
Copy link
Author

netzknecht commented Nov 13, 2023

Commit f7c8caf changes the behavior the relevant models gets loaded from the database. Because all query conditions for searching and filtering are already applied on the queries per model before and the models gets loaded explicitly by there ids, other conditions applied by global scopes are not necessary again and reduce performance. The getFreshBuilder() method returns a query builder with global scopes, newQueryWithoutScopes() not.

Commit dc8977e forwards methods to the query builder of the models to search for. It allows to add constraints to all models in a handy way, instead of repeating this step for all models.

@netzknecht
Copy link
Author

Unfortunately, the changes (as of now) break the eager load functionalities, which can result in a significant performance penalty:

image

see the test run

I just saw that too, unfortunately I don't have much time to researching the cause.

@fulopattila122
Copy link

fulopattila122 commented Nov 13, 2023

I just saw that too, unfortunately I don't have much time to researching the cause.

Me neither. Let's keep this open and once we have some time, let's come back and see the possible performance improvements.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants