In PHP, what is more efficient?
- 1 join query to 4 tables OR
- 4 individual database calls?
Limit will be maximum 10 in every case.
The tables are:
approvals
id | content | user_id | time_stamp
users
id | name | email
labels
id | name
label_relations
id | label_id | approval_id
One complex (but efficiently composed) call will beat 4 simple calls.
The reason is that making a database call has a large overhead, typically more than the query itself. There is:
All of which have nothing to do with getting data. You avoid doing all this (and more) 3 times by making one call.
Just make sure your query is well written – eg consider unions