A common myth in SQL is the idea that correlated subqueries are evil and slow. For example, this query here: SELECT first_name, last_name, (SELECT count(*) FROM film_actor fa WHERE fa.actor_id = a.actor_id) FROM actor a It "forces" the database engine to run a nested loop of the form (in pseudo code): for (Actor a : … Continue reading Correlated Subqueries are Evil and Slow. Or are They?
Tag: correlated subquery
CROSS JOIN, a nice example for a rarely used operation
In 95% of the cases, cartesian products originate from accidental cross join operations and cause unnecessary high load on a database. Maybe the results aren't even wrong, as someone may have applied a UNION or a DISTINCT keyword, to remove unwanted duplicates. But there are those 5% of SQL queries, where the cartesian product is … Continue reading CROSS JOIN, a nice example for a rarely used operation