pg.ddx.io pgsql-performance@postgresql.org mailing list archivehelp / color / mirror / Atom feed
From: Tim Jones <TJones@optio.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-performance@postgresql.org
Subject: Re: strange query behavior
Date: Thu, 14 Dec 2006 14:18:55 -0500
Message-ID: <47668A1334CDBF46927C1A0DFEB223D39F7C5D@mail.optiosoftware.com> (raw)
In-Reply-To: <22464.1166118515@sss.pgh.pa.us>
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>
<22464.1166118515@sss.pgh.pa.us>
ok thanks Tom I will alter the statistics and re-analyze the table.
Tim Jones
Healthcare Project Manager
Optio Software, Inc.
(770) 576-3555
-----Original Message-----
From: Tom Lane [mailto:tgl@sss.pgh.pa.us]
Sent: Thursday, December 14, 2006 12:49 PM
To: Tim Jones
Cc: pgsql-performance@postgresql.org
Subject: Re: [PERFORM] strange query behavior
"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
view thread (14+ messages)
Message-ID: <47668A1334CDBF46927C1A0DFEB223D39F7C5D@mail.optiosoftware.com> Permalink: ../47668A1334CDBF46927C1A0DFEB223D39F7C5D@mail.optiosoftware.com/ Also on: postgresql.org/message-id/47668A1334CDBF46927C1A0DFEB223D39F7C5D@mail.optiosoftware.com ·
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 using the --to and --cc options: reply via email To: pgsql-performance@postgresql.org Cc: TJones@optio.com, tgl@sss.pgh.pa.us Subject: Re: strange query behavior In-Reply-To: <47668A1334CDBF46927C1A0DFEB223D39F7C5D@mail.optiosoftware.com> * 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