pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Mark Harrison <mh@pixar.com>
To: pgsql-performance@postgresql.org
Subject: select is not using index?
Date: Wed, 04 Feb 2004 14:55:15 -0800
Message-ID: <40217853.20309@pixar.com> (raw)

We are suddenly getting slow queries on a particular table.
Explain shows a sequential scan.  We have "vacuum analyze" ed
the table.

Any hints?

Many TIA!
Mark


testdb=# \d bigtable
      Table "public.bigtable"
  Column  |  Type   | Modifiers
---------+---------+-----------
  id      | bigint  | not null
  typeid  | integer | not null
  reposid | integer | not null
Indexes: bigtable_id_key unique btree (id)
Foreign Key constraints: type FOREIGN KEY (typeid) REFERENCES types(typeid) ON UPDATE NO ACTION ON DELETE NO ACTION,
                          repository FOREIGN KEY (reposid) REFERENCES repositories(reposid) ON UPDATE NO ACTION ON DELETE NO ACTION

testdb=# select count(1) from bigtable;
   count
---------
  3056831
(1 row)

testdb=# explain select * from bigtable where id = 123;
                         QUERY PLAN
-----------------------------------------------------------
  Seq Scan on bigtable  (cost=0.00..60000.00 rows=1 width=16)
    Filter: (id = 123)
(2 rows)

testdb=# vacuum verbose analyze bigtable;
INFO:  --Relation public.bigtable--
INFO:  Pages 19200: Changed 0, Empty 0; Tup 3056831: Vac 0, Keep 0, UnUsed 207009.
         Total CPU 1.03s/0.24u sec elapsed 9.32 sec.
INFO:  Analyzing public.bigtable
VACUUM
testdb=# explain select * from bigtable where id = 123;
                         QUERY PLAN
-----------------------------------------------------------
  Seq Scan on bigtable  (cost=0.00..57410.39 rows=1 width=16)
    Filter: (id = 123)
(2 rows)

-- 
Mark Harrison
Pixar Animation Studios




view thread (3+ messages)  latest in thread

Message-ID: <40217853.20309@pixar.com>
Permalink:  ../40217853.20309@pixar.com/
Also on:    postgresql.org/message-id/40217853.20309@pixar.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: mh@pixar.com
  Subject: Re: select is not using index?
  In-Reply-To: <40217853.20309@pixar.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