Why does a simple query not use an obvious index? - Mailing list pgsql-performance

From Jack Kerkhof
Subject Why does a simple query not use an obvious index?
Date
Msg-id ENEIKKAEJOFHOIHMMOIDIEBMJCAA.jack.kerkhof@guest-tek.com
Whole thread Raw
Responses Re: Why does a simple query not use an obvious index?
Re: Why does a simple query not use an obvious index?
List 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.kerkhof@guest-tek.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.

 

pgsql-performance by date:

Previous
From: Mischa Sandberg
Date:
Subject: Re: Equivalent praxis to CLUSTERED INDEX?
Next
From: Mischa Sandberg
Date:
Subject: Re: Equivalent praxis to CLUSTERED INDEX?