partial indexed not being used. - Mailing list pgsql-novice

From Ron Arts
Subject partial indexed not being used.
Date
Msg-id 45CFB371.8020805@neonova.nl
Whole thread Raw
Responses Re: partial indexed not being used.  (Michael Fuhr <mike@fuhr.org>)
List pgsql-novice
Hello

I have a table that has a boolean column telling if that particular
record has been billed already. So most of the time that column holds
only true values.

To select the unbilled record I use the following query:

# select * where billed = false order by calldate;

and defined the following index:

# Create index cdr_billed_index on cdr (billed) where billed = false;

This query took surprisingly long, and explain seems to be telling
me the query is using a sequential scan:

=# 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)

How can I ensure the patial billing index will be used?

thanks for any insights,
Ron

Attachment

pgsql-novice by date:

Previous
From: Jan Danielsson
Date:
Subject: Selecting non-existing rows?
Next
From: Anthony Carmody
Date:
Subject: (no subject)