From: Sandro Santilli Date: Mon, 23 Feb 2015 17:32:30 +0000 (+0000) Subject: Add test for use of GiST index with && operator X-Git-Tag: 2.2.0rc1~641 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=04fe1f0c1ea9e118bd27d9f343bf52df6ceca9f6;p=postgis Add test for use of GiST index with && operator git-svn-id: http://svn.osgeo.org/postgis/trunk@13270 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/regress/regress_index.sql b/regress/regress_index.sql index c637541d6..22e141758 100644 --- a/regress/regress_index.sql +++ b/regress/regress_index.sql @@ -3,15 +3,38 @@ --- test some of the searching capabilities +CREATE FUNCTION qnodes(q text) RETURNS text +LANGUAGE 'plpgsql' AS +$$ +DECLARE + exp XML; +BEGIN + EXECUTE 'EXPLAIN (FORMAT XML, VERBOSE) ' || q INTO STRICT exp; + RETURN array_to_string( + xpath('//x:Node-Type/text()', exp, + ARRAY[ARRAY['x', 'http://www.postgresql.org/2009/explain']]), + ',' + ); +END; +$$; + -- GiST index CREATE INDEX quick_gist on test using gist (the_geom); +set enable_indexscan = off; +set enable_bitmapscan = off; +set enable_seqscan = on; + +SELECT 'scan_idx', 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; +set enable_indexscan = on; +set enable_bitmapscan = off; set enable_seqscan = off; - select num,ST_astext(the_geom) from test where the_geom && 'BOX3D(125 125,135 135)'::box3d order by num; +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; CREATE FUNCTION estimate_error(qry text, tol int) RETURNS text @@ -75,3 +98,6 @@ DROP TABLE test; DROP TABLE sample_queries; DROP FUNCTION estimate_error(text, int); + +DROP FUNCTION qnodes(text); + diff --git a/regress/regress_index_expected b/regress/regress_index_expected index 012e42245..ae75d050d 100644 --- a/regress/regress_index_expected +++ b/regress/regress_index_expected @@ -1,6 +1,8 @@ +scan_idx|Seq Scan 2594|POINT(130.504303 126.53112) 3618|POINT(130.447205 131.655289) 7245|POINT(128.10466 130.94133) +scan_seq|Index Scan 2594|POINT(130.504303 126.53112) 3618|POINT(130.447205 131.655289) 7245|POINT(128.10466 130.94133)