version ------------------------------------------------------------------------------------------------------------------ PostgreSQL 12.5 (Debian 12.5-1.pgdg100+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 8.3.0-6) 8.3.0, 64-bit (1 row) DROP TABLE CREATE TABLE CREATE INDEX COPY 46557 DROP TABLE CREATE TABLE CREATE INDEX CREATE TABLE INSERT 0 46557 INSERT 0 46557 QUERY PLAN ---------------------------------------------------------------------------------------------- Delete on t1 (cost=595.12..1201.93 rows=3602 width=12) -> Hash Join (cost=595.12..1201.93 rows=3602 width=12) Hash Cond: (((t1.id1)::text = (t2.id1)::text) AND ((t1.id2)::text = (t2.id2)::text)) -> Seq Scan on t1 (cost=0.00..487.06 rows=14406 width=170) -> Hash (cost=573.50..573.50 rows=1441 width=170) -> HashAggregate (cost=559.09..573.50 rows=1441 width=170) Group Key: (t2.id1)::text, (t2.id2)::text -> Seq Scan on t2 (cost=0.00..487.06 rows=14406 width=170) (8 rows) DELETE 46557 id1 | id2 -----+----- (0 rows) DELETE 0 INSERT 0 46557 ANALYZE QUERY PLAN ---------------------------------------------------------------------------------------------- Delete on t1 (cost=1506.92..2718.77 rows=7192 width=12) -> Hash Semi Join (cost=1506.92..2718.77 rows=7192 width=12) Hash Cond: (((t1.id1)::text = (t2.id1)::text) AND ((t1.id2)::text = (t2.id2)::text)) -> Seq Scan on t1 (cost=0.00..972.70 rows=28770 width=170) -> Hash (cost=808.57..808.57 rows=46557 width=36) -> Seq Scan on t2 (cost=0.00..808.57 rows=46557 width=36) (6 rows) DELETE 46557 id1 | id2 -----+----- (0 rows)