| From: | Erwin Brandstetter <brsaweda(at)gmail(dot)com> |
|---|---|
| To: | pgsql-general(at)postgresql(dot)org |
| Subject: | Re: how to speed up query |
| Date: | 2007-06-09 15:14:30 |
| Message-ID: | 1181402070.769668.269750@q75g2000hsh.googlegroups.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
On Jun 9, 12:15 am, Erwin Brandstetter <brsaw(dot)(dot)(dot)(at)gmail(dot)com> wrote:
> 3.) Write results of the subquery in a temp table, then DELETE:
>
> CREATE TEMP TABLE mydel AS SELECT DISTINCT dokumnr FROM firma1.rid;
> DELETE FROM firma1.dok USING mydel WHERE firma1.rid.doumnr =
> mydel.doumnr;
Ah! 3.) should read:
CREATE TEMP TABLE mydel AS SELECT DISTINCT dokumnr FROM firma1.rid;
DELETE FROM firma1.dok WHERE dokumnr NOT IN (SELECT dukumnr FROM
mydel);
Or 4.)
If "NOT IN" should be the culprit, there is an alternative:
( I seem to remember issues with its performance in the past, but
hasn't that been improved? Not sure.)
Haven't tested, whether the temp table is useful here:
CREATE TEMP TABLE mydel AS
SELECT d.dokumnr
FROM firma1.dok d
LEFT JOIN (SELECT DISTINCT dokumnr FROM firma1.rid) r USING (dokumnr)
WHERE r.dokumnr IS NULL;
DELETE FROM firma1.dok USING mydel WHERE firma1.dok.doumnr =
mydel.documnr;
Regards
Erwin
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Andreas | 2007-06-09 15:33:17 | odbc with encrypted ssl key? |
| Previous Message | Tom Lane | 2007-06-09 14:06:13 | Re: insane index scan times |