Skip site navigation (1) Skip section navigation (2)

Re: speed up query with max() and odd estimates

From: "Steinar H(dot) Gunderson" <sgunderson(at)bigfoot(dot)com>
To: pgsql-performance(at)postgresql(dot)org
Subject: Re: speed up query with max() and odd estimates
Date: 2005-04-26 20:48:53
Message-ID: 20050426204853.GA29424@uio.no (view raw or flat)
Thread:
Lists: pgsql-performance
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?

/* Steinar */
-- 
Homepage: http://www.sesse.net/

In response to

Responses

pgsql-performance by date

Next:From: Matthew NuzumDate: 2005-04-26 21:02:12
Subject: Re: speed up query with max() and odd estimates
Previous:From: Josh BerkusDate: 2005-04-26 20:45:53
Subject: Re: [HACKERS] Bad n_distinct estimation; hacks suggested?

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group