Hi, 2011/8/30 Szymon Kosok <szymon@xxxxxx>: > 2011/8/30 Ondrej Ivanič <ondrej.ivanic@xxxxxxxxx>: >> 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.ivanic@xxxxxxxxx) -- Sent via pgsql-performance mailing list (pgsql-performance@xxxxxxxxxxxxxx) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance