Re: Get closest numbers between intervals

From: Dimitri Fontaine <dfontaine(at)hi-media(dot)com>
To: xaviergxf <xaviergxf(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Get closest numbers between intervals
Date: 2009-09-01 21:51:25
Message-ID: m2vdk2uyea.fsf@hi-media.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

xaviergxf <xaviergxf(at)gmail(dot)com> writes:
> city_code, start_ip, end_ip
>
> I´m searching for the city that its between two ip´s. But, i would
> like to get the nearest´s cities too.

I'd have a look at ip4r rather than having both the start and end ip
there. The GiST index on ip4r allow for quick lookup:

SELECT * FROM ... WHERE iprange >>= '1.2.3.4'::ip4;

http://pgfoundry.org/projects/ip4r/

> Any ideas how can i search for the city proximity?

I'd have a look at earthdistance contrib, then maybe PostGIS:

http://www.postgresql.org/docs/8.4/static/earthdistance.html

Regards,
--
dim

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Lennin Caro 2009-09-01 22:01:57 Re: No buffer space available
Previous Message Himanshu Gupta 2009-09-01 20:58:42 how to use multiple schema's