Support the ongoing development of Laravel.io →
Database Eloquent
Last updated 2 years ago.
0

Let me clarify, user has many organisations and organisations has many posts. The query builder generates a inner join with a select based on all organisations ids IN() statement.

Am i misusing the ORM or this is how it works? The correct SQL is to join the tables on pivot.organisation_id=posts.organisation_id which gets you the same result and runs for milliseconds, not 25 seconds like the IN statement.

Last updated 8 years ago.
0

It's depending on your data, that you need an index. Check it may be speedup yor query.

0

saurabhd said:

It's depending on your data, that you need an index. Check it may be speedup yor query.

Indexes are crucial to performance but i don't see what that has to do with the issue i listed. Laravel is the problem, wether i put indexes or not the resulting query from the laravel orm is abysmal.

Last updated 8 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.