williamdclt
03/24/2022, 4:12 PMWITH rows AS (SELECT id FROM relation_tuple WHERE deleted_transaction <= $1) DELETE FROM relation_tuple WHERE id IN (SELECT id FROM rows);
. Why not DELETE FROM relation_tuple WHERE deleted_transaction <= $1
?
Second, there's no index on that table that PG can use for this query. PG will have to do a seq scan on the table, is there a reason behind the absence of index? In my case (20M relationships in database), such a seq scan takes 2 full minutes