Re: DELETE with filter on ctid

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: DELETE with filter on ctid
Дата
Msg-id 10502.1176152127@sss.pgh.pa.us
обсуждение исходный текст
Ответ на DELETE with filter on ctid  ("Spiegelberg, Greg" <gspiegelberg@cranel.com>)
Ответы Re: DELETE with filter on ctid  ("Spiegelberg, Greg" <gspiegelberg@cranel.com>)
Список pgsql-performance
"Spiegelberg, Greg" <gspiegelberg@cranel.com> writes:
> We have a query which generates a small set of rows (~1,000) which are
> to be used in a DELETE on the same table.  The problem we have is that
> we need to join on 5 different columns and it takes far too long.  I
> have a solution but I'm not sure it's the right one.  Instead of joining
> on 5 columns in the DELETE the join uses the ctid column.

> BEGIN;
> CREATE INDEX gregs_table_ctid_idx ON gregs_table(ctid);
> DELETE FROM gregs_table gt
>    USING (SELECT ctid FROM gregs_table WHERE ...) as s
>    WHERE gt.ctid=s.ctid;
> DROP INDEX gregs_table_ctid_idx;
> COMMIT;

Forget the index, it's useless here (hint: ctid is a physical address).
I'm wondering though why you don't just transpose the subquery's WHERE
condition into the DELETE's WHERE?  Or is this example oversimplified?

            regards, tom lane

В списке pgsql-performance по дате отправления:

Предыдущее
От: Drew Wilson
Дата:
Сообщение: how to efficiently update tuple in many-to-many relationship?
Следующее
От: Jeff Davis
Дата:
Сообщение: Re: Please humor me ...