Skip to content

Instantly share code, notes, and snippets.

@xaprb
Created December 14, 2013 20:27
Show Gist options
  • Save xaprb/a9daa2bd0fe7beca1265 to your computer and use it in GitHub Desktop.
Save xaprb/a9daa2bd0fe7beca1265 to your computer and use it in GitHub Desktop.
A nonsense query that demonstrates various aspects of EXPLAIN.
EXPLAIN
SELECT actor_id,
(SELECT 1 FROM sakila.film_actor WHERE film_actor.actor_id =
der_1.actor_id LIMIT 1)
FROM (
SELECT actor_id
FROM sakila.actor LIMIT 5
) AS der_1
UNION ALL
SELECT film_id,
(SELECT @var1 FROM sakila.rental LIMIT 1)
FROM (
SELECT film_id,
(SELECT 1 FROM sakila.store LIMIT 1)
FROM sakila.film LIMIT 5
) AS der_2;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment