Re: Deleting 173000 records takes forever, blocks async queries for unrelated records

From: "Carlo Stonebanks" <stonec(dot)register(at)sympatico(dot)ca>
To: "'Alexander Farber'" <alexander(dot)farber(at)gmail(dot)com>
Cc: "'pgsql-general'" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Deleting 173000 records takes forever, blocks async queries for unrelated records
Date: 2013-02-01 16:24:09
Message-ID: 02c101ce0098$905f5980$b11e0c80$@sympatico.ca
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

>># delete from pref_users
>>where id not in (select distinct id from pref_money) limit 10;
>>ERROR: syntax error at or near "limit"
>>LINE 2: ...ere id not in (select distinct id from pref_money) limit 10;

Or this?

DELETE FROM pref_users
WHERE id IN (
SELECT id
FROM pref_users
WHERE id NOT IN (
SELECT DISTINCT id
FROM pref_money
)
LIMIT 10
);

Saw elsewhere another suggestion with EXCEPT, which is also sexy.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Sahagian, David 2013-02-01 17:50:48 ATET, could it be made "more concurrent" ?
Previous Message Adrian Klaver 2013-02-01 14:22:59 Re: [JDBC] JDBC connection test with SSL on PG 9.2.1 server