Skip to content

DELETE with subquery doesn't delete rows #105

Closed
@jamatthews

Description

@jamatthews

Hello, sorry to file another bug report. I have a strange issue where deleting using a subquery just... doesn't work. It runs but it doesn't delete rows that it should delete.

I have two tables which are range partitioned partitioned by the same column and I'm trying to delete from one table using a sub-query to the other table.

BEGIN;
DELETE FROM table_1 WHERE partiton_column = 1 AND id IN(
    SELECT id FROM table_2 WHERE partition_column = 1
);
DELETE 0
ROLLBACK;

but using USING

BEGIN;
DELETE FROM table_1
USING table_2
WHERE table_1.partiton_column = 1 AND table_2.partition_column = 1 AND table_1.id = table_2.id;
DELETE 9744
ROLLBACK;

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions