Re: Advise about how to delete entries

Поиск
Список
Период
Сортировка
От John A Meinel
Тема Re: Advise about how to delete entries
Дата
Msg-id 43250CE1.6090602@arbash-meinel.com
обсуждение исходный текст
Ответ на Re: Advise about how to delete entries  (Kevin <kev@drule.org>)
Список pgsql-performance
Kevin wrote:
> Arnau wrote:
>
>> Hi all,
>>
>> >
>> >     COPY FROM a file with all the ID's to delete, into a temporary
>> table, and  do a joined delete to your main table (thus, only one query).
>>
>>
>>   I already did this, but I don't have idea about how to do this join,
>> could you give me a hint ;-) ?
>>
>> Thank you very much
>
>
> maybe something like this:
>
> DELETE FROM statistics_sasme s
>     LEFT JOIN temp_table t ON (s.statistic_id = t.statistic_id)
> WHERE t.statistic_id IS NOT NULL
>

Why can't you do:
DELETE FROM statistics_sasme s JOIN temp_table t ON (s.statistic_id =
t.statistic_id);

Or possibly:

DELETE FROM statistics_sasme s
      WHERE s.id IN (SELECT t.statistic_id FROM temp_table t);

I'm not sure how delete exactly works with joins, but the IN form should
be approximately correct.

John
=:->


Вложения

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

Предыдущее
От: John A Meinel
Дата:
Сообщение: Re: Prepared statement not using index
Следующее
От: Hilary Forbes
Дата:
Сообщение: Slow update