Re: Weirdly pesimistic estimates in optimizer - Mailing list pgsql-hackers

From Kevin Grittner
Subject Re: Weirdly pesimistic estimates in optimizer
Date
Msg-id 1172896564.922252.1425390979021.JavaMail.yahoo@mail.yahoo.com
Whole thread Raw
In response to Weirdly pesimistic estimates in optimizer  (David Kubečka <kubecka.dav@gmail.com>)
List pgsql-hackers
David Kubečka <kubecka.dav@gmail.com> wrote:

> I have read the optimizer README file and also looked briefly at
> the code, but this seems to be something not related to
> particular implementation of algorithm (e.g. nested loop).
> Perhaps it's the way how cost estimates are propagated down

It could be as simple as not having tuned your cost factors to
accurately reflect the relative costs of different actions in your
environment.  If you are using the default configuration, you might
want to try a few of the adjustments that are most often needed (at
least in my experience):

cpu_tuple_cost = 0.03
random_page_cost = 2
effective_cache_size = <50% to 75% of machine RAM>
work_mem = <machine RAM * 0.25 / max_connections>

You can SET these on an individual connection, one at a time or in
combination, and EXPLAIN the query to see the effects on plan
choice.

Other advice, not all of which matches my personal experience, can
be found here:

https://wiki.postgresql.org/wiki/Tuning_Your_PostgreSQL_Server

The best thing to do is experiment with different values with your
own queries and workloads to see what most accurately models your
costs (and thus produces the fastest plans).

--
Kevin Grittner
EDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company



pgsql-hackers by date:

Previous
From: Vladimir Borodin
Date:
Subject: Re: pg_upgrade and rsync
Next
From: Jan de Visser
Date:
Subject: Re: Idea: closing the loop for "pg_ctl reload"