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
Views: Raw Message | Whole Thread | Download mbox | Resend email
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

Browse pgsql-performance by date

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