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

Re: Optimizer bug??

From: Hans-Jürgen Schönig <postgres(at)cybertec(dot)at>
To: Ismail Kizir <ikizir(at)tumgazeteler(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Optimizer bug??
Date: 2004-05-24 17:17:34
Message-ID: 40B22E2E.503@cybertec.at (view raw or flat)
Thread:
Lists: pgsql-hackers
Ismail Kizir wrote:
> Hi everybody,
> 
> 1 .... EXPLAIN SELECT COUNT(*) AS c FROM articletbl WHERE
>       ((mydate BETWEEN '2004-04-24' AND '2004-05-24' )
> )
> 
> 2 .... EXPLAIN SELECT COUNT(*) AS c FROM articletbl WHERE
>       ((mydate = '2004-04-24')
> )
> 
> (I ran VACUUM ANALYZE before running those)
> 
> mydate is an indexed date column.
> The optimizer optimizes the second query but, it doesn't optimize the first
> one and decides to make a "sequential scan".
> Is this a bug?
> Or may someone explain me the reason?
> 
> Thanks in advance.
> 
> Ismail Kizir


If 2004-04-24 to 2004-05-24 make up let's say 90% of your data 
PostgreSQL will find out that it is cheaper to use a seq scan instead of 
an index.

This is not a bug at all - this is normal and desired behaviour ...

	Regards,

		Hans


-- 
Cybertec Geschwinde u Schoenig
Schoengrabern 134, A-2020 Hollabrunn, Austria
Tel: +43/720/10 1234567 or +43/664/233 90 75
www.cybertec.at, www.postgresql.at, kernel.cybertec.at


In response to

Responses

pgsql-hackers by date

Next:From: Ismail KizirDate: 2004-05-24 17:27:01
Subject: Re: Optimizer bug??
Previous:From: Ismail KizirDate: 2004-05-24 16:38:58
Subject: Optimizer bug??

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