X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 88D2BD97C8; Mon, 26 Sep 2005 16:17:30 -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 70433-09; Mon, 26 Sep 2005 19:17:23 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 17454D976D; Mon, 26 Sep 2005 16:17:23 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j8QJHN5b001897; Mon, 26 Sep 2005 15:17:23 -0400 (EDT) To: "Cristian Prieto" Cc: "'Sean Davis'" , pgsql-general@postgresql.org, pgsql-performance@postgresql.org Subject: Re: Index use in BETWEEN statement... In-reply-to: <20050926175615.BA5C21015A@mail.clickdiario.com> References: <20050926175615.BA5C21015A@mail.clickdiario.com> Comments: In-reply-to "Cristian Prieto" message dated "Mon, 26 Sep 2005 11:49:59 -0600" Date: Mon, 26 Sep 2005 15:17:23 -0400 Message-ID: <1896.1127762243@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.006 required=5 tests=[AWL=0.006] X-Spam-Level: X-Archive-Number: 200509/1036 X-Sequence-Number: 84051 "Cristian Prieto" writes: > mydb=# explain analyze select locid from geoip_block where > '216.230.158.50'::inet between start_block and end_block; > As you see it still using a sequential scan in the table and ignores the > index, any other suggestion? That two-column index is entirely useless for this query; in fact btree indexes of any sort are pretty useless. You really need some sort of multidimensional index type like rtree or gist. There was discussion just a week or three ago of how to optimize searches for intervals overlapping a specified point, which is identical to your problem. Can't remember if the question was about timestamp intervals or plain intervals, but try checking the list archives. regards, tom lane