Commit be80083d authored by Regina Obe's avatar Regina Obe

#3133 add nd index recheck tests

git-svn-id: http://svn.osgeo.org/postgis/trunk@13616 b70326c6-7e19-0410-871a-916f4a2858ee
parent f476059c
......@@ -172,7 +172,31 @@ As foo(the_geom) ;
-- without index order should match st_3ddistance order --
-- point check
SELECT '#1nd-3' As t, gid, ST_3DDistance( 'POINT(-305 998.5 1000)'::geometry, geom)::numeric(12,4) As dist3d,
('POINT(-305 998.5 1000)'::geometry <<->> geom)::numeric(12,4) As dist_knn
FROM knn_recheck_geom_nd
ORDER BY 'POINT(-305 998.5 1000)'::geometry <<->> geom LIMIT 5;
-- linestring check
SELECT '#2nd-3' As t, gid, ST_3DDistance( 'MULTILINESTRING((-95 -300 5000, 105 451 1000, 100 323 200),(-50 2000 456, 30 6000 789))'::geometry::geometry, geom)::numeric(12,4),
('MULTILINESTRING((-95 -300 5000, 105 451 1000, 100 323 200),(-50 2000 456, 30 6000 789))'::geometry <<->> geom)::numeric(12,4) As knn_dist
FROM knn_recheck_geom_nd
ORDER BY 'MULTILINESTRING((-95 -300 5000, 105 451 1000, 100 323 200),(-50 2000 456, 30 6000 789))'::geometry <<->> geom LIMIT 5;
-- lateral test
SELECT '#3nd-3' As t, a.gid, b.gid As match, ST_3DDistance(a.geom, b.geom)::numeric(15,4) As true_rn, b.knn_dist::numeric(15,4)
FROM knn_recheck_geom_nd As a
LEFT JOIN
LATERAL ( SELECT gid, geom, a.geom <<->> g.geom As knn_dist
FROM knn_recheck_geom_nd As g WHERE a.gid <> g.gid ORDER BY a.geom <<->> g.geom LIMIT 5) As b ON true
WHERE a.gid IN(1,500003,600001)
ORDER BY a.gid, true_rn;
-- create index and repeat
CREATE INDEX idx_knn_recheck_geom_nd_gist ON knn_recheck_geom_nd USING gist(geom gist_geometry_ops_nd);
vacuum analyze knn_recheck_geom_nd;
set enable_seqscan = false;
-- point check
SELECT '#1nd-3' As t, gid, ST_3DDistance( 'POINT(-305 998.5 1000)'::geometry, geom)::numeric(12,4) As dist3d,
('POINT(-305 998.5 1000)'::geometry <<->> geom)::numeric(12,4) As dist_knn
FROM knn_recheck_geom_nd
......@@ -184,7 +208,15 @@ SELECT '#2nd-3' As t, gid, ST_3DDistance( 'MULTILINESTRING((-95 -300 5000, 105 4
FROM knn_recheck_geom_nd
ORDER BY 'MULTILINESTRING((-95 -300 5000, 105 451 1000, 100 323 200),(-50 2000 456, 30 6000 789))'::geometry <<->> geom LIMIT 5;
-- TODO: add index tests
-- lateral test
SELECT '#3nd-3' As t, a.gid, b.gid As match, ST_3DDistance(a.geom, b.geom)::numeric(15,4) As true_rn, b.knn_dist::numeric(15,4)
FROM knn_recheck_geom_nd As a
LEFT JOIN
LATERAL ( SELECT gid, geom, a.geom <<->> g.geom As knn_dist
FROM knn_recheck_geom_nd As g WHERE a.gid <> g.gid ORDER BY a.geom <<->> g.geom LIMIT 5) As b ON true
WHERE a.gid IN(1,500003,600001)
ORDER BY a.gid, true_rn;
DROP TABLE knn_recheck_geom_nd;
......@@ -84,3 +84,43 @@
#2nd-3|600002|3.9950|3.9950
#2nd-3|9748|4.1707|4.1707
#2nd-3|10040|6.1761|6.1761
#3nd-3|1|292|5.4390|5.4390
#3nd-3|1|3|7.9830|7.9830
#3nd-3|1|294|9.6598|9.6598
#3nd-3|1|582|10.8780|10.8780
#3nd-3|1|583|13.4929|13.4929
#3nd-3|500003|500004|1448.3262|1448.3262
#3nd-3|500003|500002|1448.3262|1448.3262
#3nd-3|500003|500001|3424.9088|3424.9088
#3nd-3|500003|500005|3424.9088|3424.9088
#3nd-3|500003|45674|5153.7747|5153.7747
#3nd-3|600001|600002|0.0000|0.0000
#3nd-3|600001|9752|54.2730|54.2730
#3nd-3|600001|9461|54.3900|54.3900
#3nd-3|600001|9749|54.5453|54.5453
#3nd-3|600001|10041|54.6233|54.6233
#1nd-3|290|260.6797|260.6797
#1nd-3|287|264.3000|264.3000
#1nd-3|579|265.4356|265.4356
#1nd-3|285|268.1092|268.1092
#1nd-3|578|268.9919|268.9919
#2nd-3|9749|3.7272|3.7272
#2nd-3|600001|3.9451|3.9451
#2nd-3|600002|3.9950|3.9950
#2nd-3|9748|4.1707|4.1707
#2nd-3|10040|6.1761|6.1761
#3nd-3|1|292|5.4390|5.4390
#3nd-3|1|3|7.9830|7.9830
#3nd-3|1|294|9.6598|9.6598
#3nd-3|1|582|10.8780|10.8780
#3nd-3|1|583|13.4929|13.4929
#3nd-3|500003|500004|1448.3262|1448.3262
#3nd-3|500003|500002|1448.3262|1448.3262
#3nd-3|500003|500001|3424.9088|3424.9088
#3nd-3|500003|500005|3424.9088|3424.9088
#3nd-3|500003|45674|5153.7747|5153.7747
#3nd-3|600001|600002|0.0000|0.0000
#3nd-3|600001|9752|54.2730|54.2730
#3nd-3|600001|9461|54.3900|54.3900
#3nd-3|600001|9749|54.5453|54.5453
#3nd-3|600001|10041|54.6233|54.6233
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment