Re: how to speed up query - Mailing list pgsql-general

From Erwin Brandstetter
Subject Re: how to speed up query
Date
Msg-id 1181596607.159164.9790@w5g2000hsg.googlegroups.com
Whole thread Raw
In response to how to speed up query  ("Andrus" <kobruleht2@hot.ee>)
Responses Re: how to speed up query  ("Andrus" <kobruleht2@hot.ee>)
List pgsql-general
On Jun 11, 2:23 pm, "Andrus" <kobrule...@hot.ee> wrote:
> I tried
>
> CREATE TEMP TABLE mydel AS
>  SELECT r.dokumnr
>  FROM rid r
>  LEFT JOIN dok d USING (dokumnr)
>  WHERE d.dokumnr IS NULL;
> DELETE FROM rid USING mydel WHERE rid.dokumnr =mydel.dokumnr;
> drop table mydel;
>
> and this runs 1 seconds intead for 2.2 hours.
>
> Thank you very much.
> This works!
>
> It's sad that PostgreSQL cannot optimize this delete statement
> automatically.


1 second does sound a lot better than 2 hours, doesn't it? :)
As to why Postgres seems to fail, I cannot say any more, as your
description is unclear. I am pretty sure there is some
misunderstanding, though.


Regards
Erwin


pgsql-general by date:

Previous
From: Erwin Brandstetter
Date:
Subject: Re: how to speed up query
Next
From: Tom Lane
Date:
Subject: Re: trying to track down postgres deaths