Re: query plan not optimal
От | Marc Cousin |
---|---|
Тема | Re: query plan not optimal |
Дата | |
Msg-id | 52B3DE2F.10203@gmail.com обсуждение исходный текст |
Ответ на | Re: query plan not optimal (Kevin Grittner <kgrittn@ymail.com>) |
Список | 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 по дате отправления: