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 73255D98EF; Tue, 27 Sep 2005 07:46:26 -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 01495-03; Tue, 27 Sep 2005 10:46:22 +0000 (GMT) Received: from mxout1.netvision.net.il (mxout1.netvision.net.il [194.90.9.20]) by svr1.postgresql.org (Postfix) with ESMTP id F17E8D9201; Tue, 27 Sep 2005 07:46:23 -0300 (ADT) Received: from [10.0.0.1] ([62.0.102.240]) by mxout1.netvision.net.il (Sun Java System Messaging Server 6.1 HotFix 0.11 (built Jan 28 2005)) with ESMTP id <0INH000NS1XDYQD0@mxout1.netvision.net.il>; Tue, 27 Sep 2005 13:46:26 +0300 (IDT) Date: Tue, 27 Sep 2005 13:45:41 +0200 From: Yonatan Ben-Nes Subject: Re: Index use in BETWEEN statement... In-reply-to: <1896.1127762243@sss.pgh.pa.us> To: Tom Lane Cc: Cristian Prieto , 'Sean Davis' , pgsql-general@postgresql.org, pgsql-performance@postgresql.org Message-id: <433930E5.7090800@canaan.co.il> MIME-version: 1.0 Content-type: text/plain; charset=UTF-8; format=flowed Content-transfer-encoding: 7BIT X-Accept-Language: en-us, en References: <20050926175615.BA5C21015A@mail.clickdiario.com> <1896.1127762243@sss.pgh.pa.us> User-Agent: Mozilla Thunderbird 1.0.6 (Windows/20050716) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 required=5 tests=[none] X-Spam-Level: X-Archive-Number: 200509/1067 X-Sequence-Number: 84082 Tom Lane wrote: > "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 > > ---------------------------(end of broadcast)--------------------------- > TIP 4: Have you searched our list archives? > > http://archives.postgresql.org I think that Tom is talking about a discussion which I started entitled "Planner create a slow plan without an available index" search for it maybe it will help you. At the end I created an RTREE index and it did solved my problem though my data was 2 INT fields and not INET fields as yours so im not sure how can you work with that... To solve my problem I created boxes from the 2 numbers and with them I did overlapping.