Why does a simple query not use an obvious index?

From: "Jack Kerkhof" <jack(dot)kerkhof(at)guest-tek(dot)com>
To: <pgsql-performance(at)postgresql(dot)org>
Subject: Why does a simple query not use an obvious index?
Date: 2004-08-27 17:12:13
Message-ID: ENEIKKAEJOFHOIHMMOIDIEBMJCAA.jack.kerkhof@guest-tek.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

The query:
select count(*) from billing where timestamp > now()-60

should obviously use the index

CREATE INDEX billing_timestamp_idx ON billing USING btree ("timestamp"
timestamp_ops);

on a table with 1400000 rows.

But it uses a Seq Scan. If I set enable_seqscan=no, it indicates a queryplan
could not be calculated.

Why does this simple query not use the timestamp index, and how can I get it
to?

Thanks, Jack

Jack Kerkhof
Research & Development
jack(dot)kerkhof(at)guest-tek(dot)com
www.guest-tek.com
1.866.509.1010 3480

--------------------------------------------------------------------------

Guest-Tek is a leading provider of broadband technology solutions for
the hospitality industry. Guest-Tek's GlobalSuite™ high-speed Internet
solution enables hotels to offer their guests the convenience of wired
and/or wireless broadband Internet access from guest rooms, meeting rooms
and public areas.

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Josh Berkus 2004-08-27 17:14:29 Re: Query performance issue with 8.0.0beta1
Previous Message andrew 2004-08-27 16:52:15 Re: Query performance issue with 8.0.0beta1