should I increase default_statistics_target

Started by AI Rummanover 13 years ago2 messagesgeneral
Jump to latest
#1AI Rumman
rummandba@gmail.com

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?

#2Ondrej Ivanič
ondrej.ivanic@gmail.com
In reply to: AI Rumman (#1)
Re: should I increase default_statistics_target

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)