pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Jack Kerkhof <jack.kerkhof@guest-tek.com>
To: pgsql-performance@postgresql.org
Subject: Why does a simple query not use an obvious index?
Date: Fri, 27 Aug 2004 11:12:13 -0600
Message-ID: <ENEIKKAEJOFHOIHMMOIDIEBMJCAA.jack.kerkhof@guest-tek.com> (raw)

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.

view thread (28+ messages)  latest in thread

Message-ID: <ENEIKKAEJOFHOIHMMOIDIEBMJCAA.jack.kerkhof@guest-tek.com>
Permalink:  ../ENEIKKAEJOFHOIHMMOIDIEBMJCAA.jack.kerkhof@guest-tek.com/
Also on:    postgresql.org/message-id/ENEIKKAEJOFHOIHMMOIDIEBMJCAA.jack.kerkhof@guest-tek.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: jack.kerkhof@guest-tek.com
  Subject: Re: Why does a simple query not use an obvious index?
  In-Reply-To: <ENEIKKAEJOFHOIHMMOIDIEBMJCAA.jack.kerkhof@guest-tek.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox