I was able to speedup original query a lot by using CTE. It still uses seq
scan on `diff` table, but looks like it does this once:
explain
with
diff as (select id from drug_refills_diff)
delete from drug_refills
where id in (select id from diff);
Q
Oh, sorry, this happens on Postgresql 9.6.6. I've checked that on
Postgresql 10.0 query plan from setup (1)
now uses two seq scans, like in setup (2).
2017-12-01 15:03 GMT+02:00 Danylo Hlynskyi :
> Hello. I want to remove rows from first table, that exist in second
> (equality is done using PK).
Hello. I want to remove rows from first table, that exist in second
(equality is done using PK). However I experience seq scan on second table,
which counters my intuition - I think it should be index-only. Because
tables are large, performance of query is very bad.
However I got mixed results whe