PostgreSQL IN operator with subquery poor performance
问题 Why is the "IN" operator so slow when used with subquery? select * from view1 where id in (1,2,3,4,5,6,7,8,9,10) order by somedata; executes in 9ms. select * from view1 where id in (select ext_id from aggregate_table order by somedata limit 10) order by somedata; executes in 25000ms and seems to use sequential scan on the view ( view1 ) instead of index scan on primary keys returned by subquery as in does in first query. The subquery select ext_id from aggregate_table order by somedata limit