Thread: should I increase default_statistics_target

should I increase default_statistics_target

From
AI Rumman
Date:
Using explain analyze of a large query I found that in every step there are a lot difference between the number of rows  between actual and estimated.
I am using default_statistics_target 200. Should I increase it? 

Re: should I increase default_statistics_target

From
Ondrej Ivanič
Date:
Hi,

On 20 September 2012 20:49, AI Rumman <rummandba@gmail.com> wrote:
> Using explain analyze of a large query I found that in every step there are
> a lot difference between the number of rows  between actual and estimated.
> I am using default_statistics_target 200. Should I increase it?

I would keep it at default level but I would increase it per column:
ALTER TABLE <table> ALTER <column> SET STATISTICS <number>

and you can do the same for index:

ALTER TABLE <index_name> ALTER COLUMN <column> SET STATISTICS <number>

(for function indexes you need to use \d in order to see "real" column name)

Finally, you need to run analyse on that table / column

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