From: Tom Lane <tgl@sss.pgh.pa.us>
To: Tim Jones <TJones@optio.com>
Cc: pgsql-performance@postgresql.org
Subject: Re: strange query behavior
Date: Thu, 14 Dec 2006 12:48:35 -0500
Message-ID: <22464.1166118515@sss.pgh.pa.us> (raw)
In-Reply-To: <47668A1334CDBF46927C1A0DFEB223D39F7B01@mail.optiosoftware.com>
References: <47668A1334CDBF46927C1A0DFEB223D39F79A5@mail.optiosoftware.com>
<10648.1166037392@sss.pgh.pa.us>
<47668A1334CDBF46927C1A0DFEB223D39F79FA@mail.optiosoftware.com>
<12988.1166052295@sss.pgh.pa.us>
<47668A1334CDBF46927C1A0DFEB223D39F7B01@mail.optiosoftware.com>
"Tim Jones" <TJones@optio.com> writes:
> 18,273,008 rows in observationresults
> [ and n_distinct = 12942 ]
OK, so the estimated rowcounts are coming from those two numbers.
It's notoriously hard to get a decent n_distinct estimate from a small
sample :-(, and I would imagine the number of batteryidentifiers is
really a lot more than 12942?
What you need to do is increase the statistics target for
observationresults.batteryidentifier (see ALTER TABLE) and re-ANALYZE
and see if you get a saner n_distinct in pg_stats. I'd try 100 and
then 1000 as target. Or you could just increase the global default
target (see postgresql.conf) but that might be overkill.
It's still a bit odd that the case with two batteryidentifiers was
estimated fairly accurately when the other wasn't; I'll go look into
that. But in any case you need better stats if you want good plans.
regards, tom lane
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 using the --to and --cc options:
reply via email
To: pgsql-performance@postgresql.org
Cc: tgl@sss.pgh.pa.us, TJones@optio.com
Subject: Re: strange query behavior
In-Reply-To: <22464.1166118515@sss.pgh.pa.us>
* 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