Create a gist now

Instantly share code, notes, and snippets.

@xaprb /explain.sql Secret
Created Dec 14, 2013

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