pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andrew Sullivan <andrew@libertyrms.info>
To: pgsql-performance@postgresql.org
Subject: Re: strange estimate for number of rows
Date: Thu, 13 Nov 2003 16:37:03 -0500
Message-ID: <20031113213703.GJ25546@libertyrms.info> (raw)
In-Reply-To: <11160.1068754748@sss.pgh.pa.us>
References: <20031113181415.GB25546@libertyrms.info>
	<5882.1068749786@sss.pgh.pa.us>
	<3FB3DD1E.2000509@libertyrms.info>
	<11160.1068754748@sss.pgh.pa.us>

On Thu, Nov 13, 2003 at 03:19:08PM -0500, Tom Lane wrote:
> because the system can usually do all right on range estimates if you've
> let it run an ANALYZE with enough histogram bins.  Could we see the
> pg_stats row for transaction_date?

Do you want the whole thing?  I left out the really verbose bits when
I posted this in the original:

SELECT attname,null_frac,avg_width,n_distinct,correlation FROM
pg_stats where tablename = 'transactions_posted' AND attname in
('transaction_date','product_id');
     attname      | null_frac | avg_width | n_distinct | correlation
------------------+-----------+-----------+------------+-------------
 product_id       |         0 |         4 |          2 |    0.200956
 transaction_date |         0 |         8 |  -0.200791 |    0.289248

> 
> Since you need about a factor of 3 change in the cost estimate to get it to
> switch plans, changing random_page_cost by a factor of 2 ain't gonna do
> it (the other two numbers are second-order adjustments unlikely to have
> much effect, I think).  Try 1.5, or even less ... of course, you have to
> keep an eye on your other queries and make sure they don't go nuts, but
> from what I've heard about your hardware setup a low random_page_cost
> isn't out of line with the physical realities.

Actually, this one's on an internal box, and I think 1.5 is too low
-- it's really just a pair of mirrored SCSI disks on a PCI controller
in this case.  That does the trick, though, so maybe I'm just being
too conservantive.

A

-- 
----
Andrew Sullivan                         204-4141 Yonge Street
Afilias Canada                        Toronto, Ontario Canada
<andrew@libertyrms.info>                              M2P 2A8
                                         +1 416 646 3304 x110




view thread (6+ messages)  latest in thread

Message-ID: <20031113213703.GJ25546@libertyrms.info>
Permalink:  ../20031113213703.GJ25546@libertyrms.info/
Also on:    postgresql.org/message-id/20031113213703.GJ25546@libertyrms.info

 · 

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: andrew@libertyrms.info
  Subject: Re: strange estimate for number of rows
  In-Reply-To: <20031113213703.GJ25546@libertyrms.info>
  References: <20031113181415.GB25546@libertyrms.info> <5882.1068749786@sss.pgh.pa.us> <3FB3DD1E.2000509@libertyrms.info> <11160.1068754748@sss.pgh.pa.us> <20031113213703.GJ25546@libertyrms.info>

* 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