Re: 8.1 count(*) distinct: IndexScan/SeqScan

From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: pgsql-performance(at)postgresql(dot)org
Subject: Re: 8.1 count(*) distinct: IndexScan/SeqScan
Date: 2005-11-25 12:32:00
Message-ID: 20051125123200.GD14707@surnet.cl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

Steinar H. Gunderson wrote:
> On Thu, Nov 24, 2005 at 09:15:44PM -0600, Kyle Cordes wrote:
> > I have hit cases where I have a query for which there is a somewhat
> > "obvious" (to a human...) query plan that should make it possible to get
> > a query answer pretty quickly. Yet the query "never" finishes (or
> > rather, after hours of waiting I finally kill it). I assume this is
> > because of a sub-optimal query plan. But, it appears that an EXPLAIN
> > ANALYZE runs the actual query, so it takes as long as the actual query.
>
> In this case, you probably can't do better than EXPLAIN. Look at the
> estimates, find out if the cost is way high somewhere.

Also you want to make absolutely sure all the involved tables have been
ANALYZEd recently.

If you have weird cases where there is an obvious query plan and the
optimizer is not using it, by all means submit it so that developers can
take a look at how to improve the optimizer.

--
Alvaro Herrera http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Pailloncy Jean-Gerard 2005-11-25 14:47:16 Re: 8.1 count(*) distinct: IndexScan/SeqScan
Previous Message Steinar H. Gunderson 2005-11-25 11:40:17 Re: 8.1 count(*) distinct: IndexScan/SeqScan