Re: query plan not optimal - Mailing list pgsql-performance

From Marc Cousin
Subject Re: query plan not optimal
Date
Msg-id 52B3DE2F.10203@gmail.com
Whole thread Raw
In response to Re: query plan not optimal  (Kevin Grittner <kgrittn@ymail.com>)
List pgsql-performance
On 19/12/2013 21:36, Kevin Grittner wrote:
> Marc Cousin <cousinmarc@gmail.com> wrote:
>
>> Then we insert missing paths. This is one of the plans that fail
>> insert into path (path)
>>     select path from batch
>>       where not exists
>>             (select 1 from path where path.path=batch.path)
>>       group by path;
> I know you said you wanted to focus on a different query, but this
> one can easily be optimized.  Right now it is checking for an
> existing row in path for each row in batch; and it only needs to
> check once for each path.  One way to write it would be:
>
> insert into path (path)
>    select path from (select distinct path from batch) b
>      where not exists
>            (select 1 from path p where p.path = b.path);
Yeah, I know, that's why I said I didn't want to focus on this one… we
already do this optimization :)

Thanks anyway :)


pgsql-performance by date:

Previous
From: Scott Marlowe
Date:
Subject: Re: Regarding Hardware Tuning
Next
From: Shaun Thomas
Date:
Subject: Re: Unexpected pgbench result