]> granicus.if.org Git - postgis/commitdiff
Add test for index supported KNN queries
authorSandro Santilli <strk@keybit.net>
Mon, 23 Feb 2015 18:27:38 +0000 (18:27 +0000)
committerSandro Santilli <strk@keybit.net>
Mon, 23 Feb 2015 18:27:38 +0000 (18:27 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@13272 b70326c6-7e19-0410-871a-916f4a2858ee

regress/regress_index.sql
regress/regress_index_expected

index 5397dc3452d987ea693b71b6d79ee5b5ea601181..0b27132d6827a47038016117e31873f10e85bac1 100644 (file)
@@ -32,6 +32,20 @@ set enable_seqscan = off;
 SELECT 'scan_seq', qnodes('select * from test where the_geom && ST_MakePoint(0,0)');
  select num,ST_astext(the_geom) from test where the_geom && 'BOX3D(125 125,135 135)'::box3d order by num;
 
+-- Index-supported KNN query
+
+SELECT '<-> idx', qnodes('select * from test order by the_geom <-> ST_MakePoint(0,0)');
+SELECT '<-> res1',num,
+  ST_Distance(the_geom, 'LINESTRING(0 0,5 5)'::geometry)::numeric(10,2),
+  ST_astext(the_geom) from test
+  order by the_geom <-> 'LINESTRING(0 0,5 5)'::geometry LIMIT 1;
+
+SELECT '<#> idx', qnodes('select * from test order by the_geom <#> ST_MakePoint(0,0)');
+SELECT '<#> res1',num,
+  ST_Distance(the_geom, 'LINESTRING(0 0,5 5)'::geometry)::numeric(10,2),
+  ST_astext(the_geom) from test
+  order by the_geom <#> 'LINESTRING(0 0,5 5)'::geometry LIMIT 1;
+
 CREATE FUNCTION estimate_error(qry text, tol int)
 RETURNS text
 LANGUAGE 'plpgsql' VOLATILE AS $$
index ae75d050d1ea94010f4dc83d2ff715da6f88c6f0..df1b60941101cdb8207112199c83aef950003bbb 100644 (file)
@@ -6,6 +6,10 @@ scan_seq|Index Scan
 2594|POINT(130.504303 126.53112)
 3618|POINT(130.447205 131.655289)
 7245|POINT(128.10466 130.94133)
+<-> idx|Index Scan
+<-> res1|48589|0.08|POINT(2.33793712 2.44566727)
+<#> idx|Index Scan
+<#> res1|48589|0.08|POINT(2.33793712 2.44566727)
 3+=5:true
 924+=60:true
 12621+=500:true