Received: from makus.postgresql.org (makus.postgresql.org [98.129.198.125]) by mail.postgresql.org (Postfix) with ESMTP id D6B7FBBDD52 for ; Fri, 18 Nov 2011 10:51:32 -0400 (AST) Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1RRPmr-0001dj-JS for pgsql-admin@postgresql.org; Fri, 18 Nov 2011 14:51:33 +0000 Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id pAIEpGlk015584; Fri, 18 Nov 2011 09:51:16 -0500 (EST) To: Silvio Brandani cc: pgsql-admin@postgresql.org Subject: Re: database not using indexes, yet In-reply-to: <4EC66726.6060800@tech.sdb.it> References: <4EBA9AAC.9030900@tech.sdb.it> <4EC66726.6060800@tech.sdb.it> Comments: In-reply-to Silvio Brandani message dated "Fri, 18 Nov 2011 15:09:42 +0100" Date: Fri, 18 Nov 2011 09:51:16 -0500 Message-ID: <15583.1321627876@sss.pgh.pa.us> From: Tom Lane X-Archive-Number: 201111/100 X-Sequence-Number: 38694 Silvio Brandani writes: > On postgres 8.3.11 on linux centos 5 we have a table not too big with > primary key index on > Indexes: > "aida_references_pkey" PRIMARY KEY, btree (aida_reference_id) > the query not use index: > aidadb=# explain analyze select aida_reference_id from > aida.aida_references where aida_reference_id = '3145'; > QUERY PLAN > ---------------------------------------------------------------------------------------------------------------- > Seq Scan on aida_references (cost=0.00..51489.15 rows=1 width=4) > (actual time=0.173..1457.643 rows=1 loops=1) > Filter: (aida_reference_id = 3145) > Total runtime: 1457.696 ms There's nothing here to suggest that this query shouldn't use an index, so the problem is in something you didn't show us. Maybe you have enable_indexscan turned off, or maybe that index isn't really on that table, or something else. regards, tom lane