Re: Query optimization help - Mailing list pgsql-performance

From Ondrej Ivanič
Subject Re: Query optimization help
Date
Msg-id CAM6mieJaFU8+g35TLNRmd+kOieoY7Gk06x1MvnyaTy0EOvJxEQ@mail.gmail.com
Whole thread Raw
In response to Query optimization help  (Szymon Kosok <szymon@mwg.pl>)
Responses Re: Query optimization help
List pgsql-performance
Hi,

On 30 August 2011 15:36, Szymon Kosok <szymon@mwg.pl> wrote:
> Hello,
>
> I asked that question on StackOverflow, but didn't get any valuable
> response, so I'll ask it here. :)
>
> I have such query:

Could you please re-post your explain using this web site:
http://explain.depesz.com/ and post links to Stackoverflow question?
What is your Postgres version? Database settings?
I see huge discrepancy between predicted and actual row numbers (like
1264420 vs 485). I would try the following:

- check column statistics (pg_stasts) and focus on the following
columns: n_distinct, null_frac, most_common_vals. If they are way-off
from the actual values then you should tweak (auto)analyze process:
run manual/auto analyse more often (check pg_stat_user_tables),
increase default_statistics_target (per column or global)

- try to disable nested loop join (set enable_nestloop=off)

--
Ondrej Ivanic
(ondrej.ivanic@gmail.com)

pgsql-performance by date:

Previous
From: Venkat Balaji
Date:
Subject: Re: Re: How to track number of connections and hosts to Postgres cluster
Next
From: Scott Marlowe
Date:
Subject: Re: Re: How to track number of connections and hosts to Postgres cluster