X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id B0F94D1C98E for ; Wed, 4 Feb 2004 22:55:43 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 98117-01 for ; Wed, 4 Feb 2004 18:55:38 -0400 (AST) Received: from busybox.pixar.com (busybox.pixar.com [138.72.18.213]) by svr1.postgresql.org (Postfix) with ESMTP id 8059ED1B837 for ; Wed, 4 Feb 2004 18:55:31 -0400 (AST) Received: from pixar.com (dreadnok.pixar.com [138.72.16.110]) by busybox.pixar.com (8.12.8/8.12.8) with ESMTP id i14MtFHw030245 for ; Wed, 4 Feb 2004 14:55:15 -0800 Message-ID: <40217853.20309@pixar.com> Date: Wed, 04 Feb 2004 14:55:15 -0800 From: Mark Harrison User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.0.0) Gecko/20020529 X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: select is not using index? Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/65 X-Sequence-Number: 5589 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