Skip site navigation (1) Skip section navigation (2)

Re: Query optimization help

From: Ondrej Ivanič <ondrej(dot)ivanic(at)gmail(dot)com>
To: pgsql-performance(at)postgresql(dot)org
Subject: Re: Query optimization help
Date: 2011-08-30 08:20:08
Message-ID: CAM6mie+xUUB-Dv8Bw0eV1qA5kkyJD0UJtfCBbs1HpAkGC7-QTQ@mail.gmail.com (view raw or flat)
Thread:
Lists: pgsql-performance
Hi,

2011/8/30 Szymon Kosok <szymon(at)mwg(dot)pl>:
> 2011/8/30 Ondrej Ivanič <ondrej(dot)ivanic(at)gmail(dot)com>:
>> Could you please re-post your explain using this web site:
>> http://explain.depesz.com/ and post links to Stackoverflow question?
>
> Here it is: http://explain.depesz.com/s/Iaa
>
>> - try to disable nested loop join (set enable_nestloop=off)

Thanks, I would try to "materialise" spoleczniak_tablica table. Your
query looks like this:
select ...
from spoleczniak_tablica
inner join ...
where ...
order by spoleczniak_tablica.id desc
limit 21

So I would rewrite your query like this:
select ...
from (
     select ...
     from spoleczniak_tablica
     where ....
     order by spoleczniak_tablica.id desc
     limit 21
) as x
inner join ...


-- 
Ondrej Ivanic
(ondrej(dot)ivanic(at)gmail(dot)com)

In response to

pgsql-performance by date

Next:From: Grzegorz JaśkiewiczDate: 2011-08-30 09:43:48
Subject: Re: 8.4 optimization regression?
Previous:From: Szymon KosokDate: 2011-08-30 07:44:10
Subject: Re: Query optimization help

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group