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

Re: partial indexed not being used.

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Ron Arts <ron(dot)arts(at)neonova(dot)nl>
Cc: Michael Fuhr <mike(at)fuhr(dot)org>, pgsql-novice(at)postgresql(dot)org
Subject: Re: partial indexed not being used.
Date: 2007-02-12 14:21:34
Message-ID: 6801.1171290094@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-novice
Ron Arts <ron(dot)arts(at)neonova(dot)nl> writes:
> # select count(*) from cdr where billed = false;
>   count
> -------
>       3
> (1 row)

>> =# explain select cdr.* from cdr where billed = false order by calldate;
>>
>>                             QUERY PLAN
>> -------------------------------------------------------------------
>>  Sort  (cost=37448.75..37526.94 rows=31273 width=465)
>>    Sort Key: calldate
>>    ->  Seq Scan on cdr  (cost=0.00..20323.81 rows=31273 width=465)
                                                ^^^^^^^^^^
>>          Filter: (billed = false)

You haven't ANALYZEd this table (lately, or perhaps ever).  The planner
is thus working with a default selectivity estimate (which I think is
50% for a bool column --- that seems to match your numbers anyway), and
that leads it to the conclusion that a seqscan is the right thing.
Which it would indeed be, if half the table has to be retrieved.

			regards, tom lane

In response to

Responses

pgsql-novice by date

Next:From: Ron ArtsDate: 2007-02-12 16:31:57
Subject: Re: partial indexed not being used.
Previous:From: AndreasDate: 2007-02-12 14:11:50
Subject: Re: Help whit schemas

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