pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Kevin Grittner <Kevin.Grittner@wicourts.gov>
To: Sok Ann Yap <sokann@gmail.com>
Cc: pgsql-performance@postgresql.org
Subject: Re: reducing random_page_cost from 4 to 2 to force index scan
Date: Wed, 27 Apr 2011 18:23:36 -0500
Message-ID: <4DB85F28020000250003CFA1@gw.wicourts.gov> (raw)
In-Reply-To: <BANLkTi=NFNTZ8n4zB0L+TLdurnSnnpx9Pw@mail.gmail.com>
References: <4DB7C88A020000250003CF10@gw.wicourts.gov>
	<BANLkTi=NFNTZ8n4zB0L+TLdurnSnnpx9Pw@mail.gmail.com>

Sok Ann Yap <sokann@gmail.com> wrote:
 
> Anyway, the overhead of spawning 44 extra queries means that it is
> still better off for me to stick with the original query and tune
> PostgreSQL to choose index scan.
 
Maybe, but what is *best* for you is to tune PostgreSQL so that your
costs are accurately modeled, at which point it will automatically
pick the best plan for most or all of your queries without you
needing to worry about it.
 
If you set your effective_cache_size to the sum of shared_buffers
and what your OS reports as cache after you've been running a while,
that will help the optimizer know what size index fits in RAM, and
will tend to encourage index use.  If the active portion of your
data is heavily cached, you might want to set random_page_cost and
seq_page_cost to the same value, and make that value somewhere in
the 0.1 to 0.05 range.  If you have moderate caching, using 1 and 2
can be good.
 
If you're still not getting reasonable plans, please post again with
more information about your hardware along with the query and its
EXPLAIN ANALYZE output.
 
-Kevin



view thread (43+ messages)  latest in thread

Message-ID: <4DB85F28020000250003CFA1@gw.wicourts.gov>
Permalink:  ../4DB85F28020000250003CFA1@gw.wicourts.gov/
Also on:    postgresql.org/message-id/4DB85F28020000250003CFA1@gw.wicourts.gov

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-performance@postgresql.org
  Cc: Kevin.Grittner@wicourts.gov, sokann@gmail.com
  Subject: Re: reducing random_page_cost from 4 to 2 to force index scan
  In-Reply-To: <4DB85F28020000250003CFA1@gw.wicourts.gov>
  References: <4DB7C88A020000250003CF10@gw.wicourts.gov> <BANLkTi=NFNTZ8n4zB0L+TLdurnSnnpx9Pw@mail.gmail.com> <4DB85F28020000250003CFA1@gw.wicourts.gov>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox