Re: Optimizer bug??

From: Gaetano Mendola <mendola(at)bigfoot(dot)com>
To: Ismail Kizir <ikizir(at)tumgazeteler(dot)com>
Subject: Re: Optimizer bug??
Date: 2004-05-24 21:47:17
Message-ID: 40B26D65.4050808@bigfoot.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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??

Try to do an explain analyze for both queries, and repeat
the explain analyze but before disable the sequential scan
( "set enable_seq_scan=off" ).

For sure what do you have is extimated cost higher, what
do you have to do is decrease that cost, try with these
values:

random_page_cost = 2.5
cpu_tuple_cost = 0.005
cpu_index_tuple_cost = 0.0005
cpu_operator_cost = 0.0025

these are values that are good for a modern machine.

Hackers, what about to decrease the default values for this
quantities ?

Regards
Gaetano Mendola

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andreas Pflug 2004-05-24 23:15:48 Re: Big problem
Previous Message Stephan Szabo 2004-05-24 20:52:25 Re: Optimizer bug??