From: | Bruce Momjian <bruce(at)momjian(dot)us> |
---|---|
To: | Heikki Linnakangas <hlinnakangas(at)vmware(dot)com> |
Cc: | Alexander Korotkov <aekorotkov(at)gmail(dot)com>, Michael Paquier <michael(dot)paquier(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, PostgreSQL mailing lists <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: Commit fest 2014-12, let's begin! |
Date: | 2014-12-19 03:02:41 |
Message-ID: | 20141219030241.GC26676@momjian.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Mon, Dec 15, 2014 at 03:58:39PM +0200, Heikki Linnakangas wrote:
> >WITH closest_candidates AS (
> > SELECT
> > streets.gid,
> > streets.name,
> > streets.geom
> > FROM
> > nyc_streets streets
> > ORDER BY
> > streets.geom <->
> > 'SRID=26918;POINT(583571.905921312 4506714.34119218)'::geometry
> > LIMIT 100
> >)
> >SELECT gid, name
> >FROM closest_candidates
> >ORDER BY
> > ST_Distance(
> > geom,
> > 'SRID=26918;POINT(583571.905921312 4506714.34119218)'::geometry
> > )
> >LIMIT 1;
> >
> >See blog posts:
> >http://blog.light42.com/wordpress/?p=102
> >http://workshops.boundlessgeo.com/postgis-intro/knn.html
>
> Ugh. Ok, sold :-). I'll review...
Just to summarize, the index can only be created on the <-> operator
because that indexes on the center of the bounding box:
http://postgis.net/docs/manual-2.1/geometry_distance_centroid.html
You can't index on ST_Distance() because that computes the minimum
distance between the two objects, which is different for different
points:
http://postgis.net/docs/manual-2.1/ST_Distance.html
I am embarrassed by the LIMIT 100 hack they have to use above to find
the closest polygon to a given point, and this recheck patch is going to
fix that. I think this will remove the most significant PostGIS wart.
--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com
+ Everyone has their own god. +
From | Date | Subject | |
---|---|---|---|
Next Message | Stephen Frost | 2014-12-19 03:24:59 | Re: Role Attribute Bitmask Catalog Representation |
Previous Message | Alvaro Herrera | 2014-12-19 02:51:37 | Re: NUMERIC private methods? |