Thread: DELETE FROM A BLACK LIST

DELETE FROM A BLACK LIST

From
luca.scaramella@recom.it
Date:
Hi all,
I have a Blacklist table containing about 1000 ID to delete from another
table (T1 about 1440294 records)
If i use the SQL

DELETE FROM T1 WHERE T1.ID IN (SELECT BLACKLIST.ID FROM BLACKLIST)

the operation is very slow .

There is a faster way to do the same operation??

Thanks
Luca






Re: DELETE FROM A BLACK LIST

From
Steve Crawford
Date:
delete from t1 where not exists (select blacklist.id from blacklist where 
blacklist.id=t1.id);

(if I recall the full syntax correctly - you get the idea: use "exists")

Cheers,
Steve

On Wednesday 05 March 2003 2:27 am, luca.scaramella@recom.it wrote:
> Hi all,
> I have a Blacklist table containing about 1000 ID to delete from another
> table (T1 about 1440294 records)
> If i use the SQL
>
> DELETE FROM T1 WHERE T1.ID IN (SELECT BLACKLIST.ID FROM BLACKLIST)
>
> the operation is very slow .
>
> There is a faster way to do the same operation??
>
> Thanks
> Luca
>
>
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: you can get off all lists at once with the unregister command
>     (send "unregister YourEmailAddressHere" to majordomo@postgresql.org)


Re: DELETE FROM A BLACK LIST

From
Bruno Wolff III
Date:
On Wed, Mar 05, 2003 at 11:27:54 +0100, luca.scaramella@recom.it wrote:
> Hi all,
> I have a Blacklist table containing about 1000 ID to delete from another
> table (T1 about 1440294 records)
> If i use the SQL
> 
> DELETE FROM T1 WHERE T1.ID IN (SELECT BLACKLIST.ID FROM BLACKLIST)

Use:

delete from t1 where t1.id = blacklist.id;