Skip to content

Issue when relation more than one same relation and no results. #85

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
maiconmva opened this issue Jun 24, 2021 · 3 comments
Open

Issue when relation more than one same relation and no results. #85

maiconmva opened this issue Jun 24, 2021 · 3 comments
Labels
good first issue Good for newcomers

Comments

@maiconmva
Copy link

Hello, i think i found a issue,

I have this model with 3 relations with Person Model.

and when i filter to show some record without relations with persons the N+1 log shows...

image

But if u see the querie, shows the correct way, its not a N+1 error....
image

this is the n+1 log;
image

@thevalo
Copy link

thevalo commented Aug 22, 2022

Do we have the same problem?
image

The query:
$subscription = Subscription::with('transaction')->where('tenant_id', tenant('id'))->first();

@PetengDedet
Copy link

Yes it is. Have similar problem.
It is a false positive.

In my case below query is exactly the same but actually its a different context.

The first one is for getting post_author and the second one is for updater.

image

@hussain-jtr
Copy link

hussain-jtr commented May 30, 2024

I have same issue with laravel-medialibrary

my code:
Activity::with(['categories', 'categories.image', 'categories.bannerImage'])->get()

saying:

local.INFO: Model: App\Models\Category
Relation: Spatie\MediaLibrary\MediaCollections\Models\Media
Num-Called: 2
Call-Stack:...

For now I set QUERY_DETECTOR_THRESHOLD=2 but what if i need some more eager loading with different relationship like categories.featureImage

It should use N+1 problem detection for same queries not for same model

@hussainalihussain

@mechelon mechelon added the good first issue Good for newcomers label Oct 4, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

5 participants