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 AA8BD32A05D for ; Wed, 6 Oct 2004 08:31:08 +0100 (BST) 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 98677-02 for ; Wed, 6 Oct 2004 07:30:57 +0000 (GMT) Received: from www.hanseo.hs.kr (unknown [210.90.30.1]) by svr1.postgresql.org (Postfix) with ESMTP id 4FAB232A256 for ; Wed, 6 Oct 2004 08:30:56 +0100 (BST) Received: from [192.168.123.8] ([211.238.40.5]) (authenticated bits=0) by www.hanseo.hs.kr (8.12.9/8.12.9) with ESMTP id i967Ud0X003214 for ; Wed, 6 Oct 2004 16:30:44 +0900 Message-ID: <41639F3C.4050103@siche.net> Date: Wed, 06 Oct 2004 16:31:08 +0900 From: HyunSung Jang User-Agent: Mozilla Thunderbird 0.8 (Windows/20040913) X-Accept-Language: ko-kr, ko, en-us, en MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: why my query is not using index?? Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit 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: 200410/131 X-Sequence-Number: 8607 postgres=# explain ANALYZE select * from test where today < '2004-01-01'; QUERY PLAN ---------------------------------------------------------------------------------------------------- Seq Scan on test (cost=0.00..19.51 rows=334 width=44) (actual time=0.545..2.429 rows=721 loops=1) Filter: (today < '2004-01-01 00:00:00'::timestamp without time zone) Total runtime: 3.072 ms (3 rows) postgres=# explain ANALYZE select * from test where today > '2003-01-01' and today < '2004-01-01'; QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------------------- Index Scan using idx_today on test (cost=0.00..18.89 rows=6 width=44) (actual time=0.055..1.098 rows=365 loops=1) Index Cond: ((today > '2003-01-01 00:00:00'::timestamp without time zone) AND (today < '2004-01-01 00:00:00'::timestamp without time zone)) Total runtime: 1.471 ms (3 rows) hello I was expected 1st query should using index, but it doesn't 2nd query doing perfect as you see. can you explain to me why it's not doing that i expected?? now I'm currently using postgresql 8.0pre3 on linux /hyunsung jang.