Postgres NOT IN performance

前端 未结 4 549
暗喜
暗喜 2020-12-28 22:09

Any ideas how to speed up this query?

Input

EXPLAIN SELECT entityid FROM entity e

LEFT JOIN level1entity l1 ON l1.level1id = e.level1_level1id
LEFT         


        
4条回答
  •  温柔的废话
    2020-12-28 22:42

    ok my solution was

    • select all entities
    • left join all entities which have one of the ids (without the not is is faster) on the entityid
    • select all rows where the joined select is NULL

    as explained in

    http://blog.hagander.net/archives/66-Speeding-up-NOT-IN.html

提交回复
热议问题