X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id E6B2B5E4701 for ; Tue, 17 Aug 2004 11:23:07 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 94532-04 for ; Tue, 17 Aug 2004 14:23:01 +0000 (GMT) Received: from mail.bluecatnetworks.com (mail.bluecatnetworks.com [209.167.177.42]) by svr1.postgresql.org (Postfix) with ESMTP id 157BB5E46F5 for ; Tue, 17 Aug 2004 11:22:58 -0300 (ADT) Received: from [172.18.0.2] ([172.18.0.2]:56988 "EHLO COLOSSUS.dyadem.corp" ident: "NO-IDENT-SERVICE[2]") by mail.bluecatnetworks.com with ESMTP id convert rfc822-to-8bit; Tue, 17 Aug 2004 10:22:59 -0400 X-MimeOLE: Produced By Microsoft Exchange V6.0.6249.0 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8BIT Subject: I could not get postgres to utilizy indexes Date: Tue, 17 Aug 2004 10:22:59 -0400 Message-ID: <5DEC3FFCDE2F7C4DA45433EE09A4F22C01A3FFCA@colossus.dyadem.corp> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: I could not get postgres to utilizy indexes Thread-Index: AcSEZbJwv6sR2bdDTJ+eEmRsHloP7w== From: "Igor Artimenko" To: X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200408/273 X-Sequence-Number: 7909 Hi verybody! I can't make use of indexes even I tried the same test by changing different settings in postgres.conf like geqo to off/on & geqo related parameters, enable_seqscan off/on & so on. Result is the same. Here is test itself: I've created simplest table test and executed the same statement "explain analyze select id from test where id = 50000;" Few times I added 100,000 records, applied vacuum full; and issued above explain command. Postgres uses sequential scan instead of index one. Of cause Time to execute the same statement constantly grows. In my mind index should not allow time to grow so much. Why Postgres does not utilizes primary unique index? What I'm missing? It continue growing even there are 1,200,000 records. It should at least start using index at some point. Details are below: 100,000 records: QUERY PLAN ---------------------------------------------------------------------------------------------------- Seq Scan on test (cost=0.00..2427.00 rows=2 width=8) (actual time=99.626..199.835 rows=1 loops=1) Filter: (id = 50000) Total runtime: 199.990 ms 200,000 records: QUERY PLAN ----------------------------------------------------------------------------------------------------- Seq Scan on test (cost=0.00..4853.00 rows=2 width=8) (actual time=100.389..402.770 rows=1 loops=1) Filter: (id = 50000) Total runtime: 402.926 ms 300,000 records: QUERY PLAN ----------------------------------------------------------------------------------------------------- Seq Scan on test (cost=0.00..7280.00 rows=1 width=8) (actual time=100.563..616.064 rows=1 loops=1) Filter: (id = 50000) Total runtime: 616.224 ms (3 rows) I've created test table by script: CREATE TABLE test ( id int8 NOT NULL DEFAULT nextval('next_id_seq'::text) INIQUE, description char(50), CONSTRAINT users_pkey PRIMARY KEY (id) ); CREATE SEQUENCE next_id_seq INCREMENT 1 MINVALUE 1 MAXVALUE 10000000000 START 1 CACHE 5 CYCLE; I use postgres 7.4.2