Skip site navigation (1) Skip section navigation (2)

Re: Advise about how to delete entries

From: John A Meinel <john(at)arbash-meinel(dot)com>
To: Kevin <kev(at)drule(dot)org>
Cc: arnaulist(at)andromeiberica(dot)com, pgsql-performance(at)postgresql(dot)org
Subject: Re: Advise about how to delete entries
Date: 2005-09-12 05:06:41
Message-ID: 43250CE1.6090602@arbash-meinel.com (view raw or flat)
Thread:
Lists: 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
=:->

In response to

pgsql-performance by date

Next:From: Hilary ForbesDate: 2005-09-12 09:14:25
Subject: Slow update
Previous:From: John A MeinelDate: 2005-09-12 04:58:34
Subject: Re: Prepared statement not using index

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group