1
为什么这个LEFT JOIN的表现比LEFT JOIN LATERAL差很多?
我有以下表格(来自Sakila数据库): 电影:film_id是pkey 演员:actor_id是pkey film_actor:film_id和actor_id是影片/演员的键 我正在选择一部特定的电影。对于这部电影,我还希望所有演员都参与该电影。我对此有两个查询:一个带有a LEFT JOIN和一个带有a LEFT JOIN LATERAL。 select film.film_id, film.title, a.actors from film left join ( select film_actor.film_id, array_agg(first_name) as actors from actor inner join film_actor using(actor_id) group by film_actor.film_id ) as a on a.film_id = film.film_id where film.title = 'ACADEMY DINOSAUR' order by film.title; select film.film_id, …