From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | "Charley L(dot)Tiggs" <ctiggs(at)xpressdocs(dot)com> |
Cc: | pgsql-novice(at)postgresql(dot)org |
Subject: | Re: Search speed issues |
Date: | 2003-05-03 01:47:02 |
Message-ID: | 11298.1051926422@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice |
"Charley L.Tiggs" <ctiggs(at)xpressdocs(dot)com> writes:
> SELECT (first_name || ' ' || last_name) AS name,
> (house_number || ' ' || fract::varchar || ' ' ||
> street_prefix_dir::varchar || ' ' || street_name || ' ' ||
> street_suffix::varchar || ' ' || street_post_dir::varchar) AS address,
> city,
> state,
> zip
> FROM address
> WHERE latitude >= $minLat AND
> latitude <= $maxLat AND
> longitude >= $minLong AND
> longitude <= $maxLong
> ORDER BY ((abs($property_long - longitude)) * 1000) +
> ((abs($property_lat - latitude)) * 1000)
> LIMIT 100
Seems like a two-column index on (latitude, longitude) is what you need.
You could get fancy and try mucking about with box overlap operators and
rtree indexes, but I suspect the 2-column btree will work well enough.
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Seth Nickell | 2003-05-03 03:50:46 | libpg: large object problems |
Previous Message | Charley L.Tiggs | 2003-05-03 00:40:00 | Search speed issues |