4 ms·
7 isn't necessarily nothing. Each join is O(log(n)), so I believe you're stuck with O(log(n)^7) as a worst case, although in practice it will probably not be so
by schrodinger 13y ago
7 isn't necessarily nothing. Each join is O(log(n)), so I believe you're stuck with O(log(n)^7) as a worst case, although in practice it will probably not be so bad since one of the joins will probably limit the result set significantly.
The other problem is that with 7 joins, that's 7! permutations of possible orders in which the database can perform the join. That's a lot of combinations, and often you can run into the optimizer picking a poor plan. Sometimes it picks a good plan initially, and then as your data set changes it can choose a different, suboptimal plan. This leads to unpredictable performance.
I think that in practice, you're best off sticking with only a few joins...
- jmelloy 13y agoIf you're regularly doing 7 joins it's a good sign of an over normalized databased.
- jacques_chester 13y agoNonsense. It very much depends on the problem domain.