Re: Index use in BETWEEN statement...

From: Yonatan Ben-Nes <da(at)canaan(dot)co(dot)il>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Cristian Prieto <cristian(at)clickdiario(dot)com>, 'Sean Davis' <sdavis2(at)mail(dot)nih(dot)gov>, pgsql-general(at)postgresql(dot)org, pgsql-performance(at)postgresql(dot)org
Subject: Re: Index use in BETWEEN statement...
Date: 2005-09-27 11:45:41
Message-ID: 433930E5.7090800@canaan.co.il
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-performance

Tom Lane wrote:
> "Cristian Prieto" <cristian(at)clickdiario(dot)com> 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.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Dawid Kuroczko 2005-09-27 12:08:33 Re: Performance woes relating to DISTINCT (I think)
Previous Message Yonatan Ben-Nes 2005-09-27 11:34:37 Re: How many insert + update should one transaction handle?

Browse pgsql-performance by date

  From Date Subject
Next Message Gnanavel S 2005-09-27 12:05:58 Re: PostgreSQL overall design
Previous Message Андрей Репко 2005-09-27 11:37:31 Re: Index not used on group by