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;
I was reading about using EXPLAIN, and the explain result for this query had a row with select_type as UNION_RESULT. However, I don't get this row. Can someone help me understand this behavior?
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
1 PRIMARY <derived3> NULL ALL NULL NULL NULL NULL 5 100.00 NULL
3 DERIVED actor NULL index NULL idx_actor_last_name 182 NULL 200 100.00 Using index
2 DEPENDENT SUBQUERY film_actor NULL ref PRIMARY PRIMARY 2 der_1.actor_id 1 100.00 Using index
4 UNION <derived6> NULL ALL NULL NULL NULL NULL 5 100.00 NULL
6 DERIVED film NULL index NULL idx_fk_language_id 1 NULL 881 100.00 Using index
7 SUBQUERY store NULL index NULL idx_unique_manager 1 NULL 2 100.00 Using index
5 UNCACHEABLE SUBQUERY rental NULL index NULL idx_fk_staff_id 1 NULL 15005 100.00 Using index
1 Answer 1
I was reading about using EXPLAIN, and the explain result for this query had a row with select_type as UNION_RESULT. However, I don't get this row.
UNION ALL
without any additional operation over a summarized dataset does not need UNION_RESULT
. - https://dba.stackexchange.com/users/150107