3 ms·
IDK about the profiler... but I have a hard time believing why the union of 2 joins will be faster than filtering first and then join the results :thinking:
by mtzaldo 7y ago
IDK about the profiler... but I have a hard time believing why the union of 2 joins will be faster than filtering first and then join the results :thinking:
- Izkata 7y agoYeah, seeing "sort" in the union-based plan also threw me for a moment about why that would be any faster. Normally sorts kill performance, especially compared to the merge join in the "ugly" version. I think the key is in the description afterwards, where each subquery only returns 1 row. Which just reinforces: measure everything, this advice may not be generally applicable.
- Semiapies 7y agoI've seen it work exactly the same way in MSSQL, weirdly enough.