From: Matthew Nuzum <mattnuzum@gmail.com>
To: pgsql-performance@postgresql.org
Subject: Re: speed up query with max() and odd estimates
Date: Tue, 26 Apr 2005 16:02:12 -0500
Message-ID: <f3c0b408050426140240a246cb@mail.gmail.com> (raw)
In-Reply-To: <20050426204853.GA29424@uio.no>
References: <f3c0b40805042613167c47c7e9@mail.gmail.com>
<20050426204853.GA29424@uio.no>
On 4/26/05, Steinar H. Gunderson <sgunderson@bigfoot.com> wrote:
> On Tue, Apr 26, 2005 at 03:16:57PM -0500, Matthew Nuzum wrote:
> > Seq Scan on usage_access (cost=0.00..1183396.40 rows=12713851
> > width=116) (actual time=481796.22..481839.43 rows=3343 loops=1)
>
> That's a gross misestimation -- four orders of magnitude off!
>
> Have you considering doing this in two steps, first getting out whatever
> comes from the subquery and then doing the query? Have you ANALYZEd recently?
> Do you have an index on atime?
>
Yes, there is an index on atime. I'll re-analyze but I'm pretty
certain that runs nightly.
Regarding two steps, are you suggesting:
begin;
select * into temp_table...;
select * from temp_table...;
drop temp_table;
rollback;
I have not tried that but will.
BTW, I created an index on clients just for the heck of it and there
was no improvement. (actually, a slight degradation)
--
Matthew Nuzum
www.bearfruit.org
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: mattnuzum@gmail.com
Subject: Re: speed up query with max() and odd estimates
In-Reply-To: <f3c0b408050426140240a246cb@mail.gmail.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