3 ms·
> It’s not the most optimized way to do it, but more often then not, the query plan is perfectly fine. Depending on the details, the query plan might be exactl
by paol 3y ago
> It’s not the most optimized way to do it, but more often then not, the query plan is perfectly fine.
Depending on the details, the query plan might be exactly the same. I remember once (in SQL Server 2000, so long time ago) writing the same query in 3 completely different ways, only to see the DB generate the same plan for each one.
It would surprise most people how sophisticated the query transformations databases can do.
- deleted 3y ago[deleted]
- dunham 3y agoI had one case, with the same SQL server, where rewriting to a join made the query much faster. That was a data changing statement though, and I think the semantics demanded it rerun the subselect. More recently, I've found that mysql sometimes behaves poorly with subselects, so I tend to avoid them out of habit.