Re: Optimizer bug??

From: Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com>
To: Ismail Kizir <ikizir(at)tumgazeteler(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Optimizer bug??
Date: 2004-05-24 20:52:25
Message-ID: 20040524134717.U55261@megazone.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


On Mon, 24 May 2004, Ismail Kizir wrote:

> Hi all,
>
> > give us the result of these queries:
> > SELECT COUNT(*) FROM articletbl;
>
> 268726 records, it takes 34169 ms. to compute this
>
> > SELECT COUNT(*) AS c FROM articletbl WHERE
> > mydate BETWEEN '2004-04-24' AND '2004-05-24';
>
> 18982 records, it takes 34249 ms. to compute this.
>
> > SELECT COUNT(*) AS c FROM articletbl WHERE
> > mydate = '2004-04-24';
> 850 records, it takes only 40 ms. to compute this.
>
> It is evident that there is a problem here! Am I wrong??

What does explain analyze show for the between query (not just explain)
and what does it show if enable_seqscan is set to false? It's possible
that it's badly overestimating the cost of the range query, but that's
hard to say at this point. There is a point at which in general an index
scan becomes more costly than a sequence scan, and it's possible to move
that point by changing optimizer settings in the configuration.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Gaetano Mendola 2004-05-24 21:47:17 Re: Optimizer bug??
Previous Message Sérgio Monteiro Basto 2004-05-24 20:32:43 Re: Big problem