[postgis-devel] Why doesn't knn work on table1.geom <#>table2.geom

Paul Ramsey pramsey at opengeo.org
Sun Oct 2 08:49:05 PDT 2011


You'll have to trace but probably it plans out as impossible (ie, the
knn code can't handle it, so it goes down a different path). Unless
you see it working on internal native pgsql points, in which case my
implementation is faulty.

P.

On Sun, Oct 2, 2011 at 3:58 AM, Nicklas Avén <nicklas.aven at jordogskog.no> wrote:
> I have been playing some with the new knn-implementation.
>
> If I write the query as Paul illustrates like
>
>
>
> SELECT id, table1.geom<->ST_SetSrid('POINT(1,2)'::geometry, 3021) as
> distance
> FROM table1
> ORDER BY distance
> LIMIT 10;
>
> Then the index kicks in and works as expected.
>
> But if I take the second geometry, the point directlu from a table it
> doesn't work like:
>
> SELECT id, table1.geom<->table2.geom as distance
> FROM table1, (SELECT geom FROM table1 where gid=1;) AS table2
> ORDER BY distance
> LIMIT 10;
>
> /Nicklas
>
> _______________________________________________
> postgis-devel mailing list
> postgis-devel at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-devel
>



More information about the postgis-devel mailing list