]> granicus.if.org Git - postgis/commitdiff
Add test for use of GiST index with && operator
authorSandro Santilli <strk@keybit.net>
Mon, 23 Feb 2015 17:32:30 +0000 (17:32 +0000)
committerSandro Santilli <strk@keybit.net>
Mon, 23 Feb 2015 17:32:30 +0000 (17:32 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@13270 b70326c6-7e19-0410-871a-916f4a2858ee

regress/regress_index.sql
regress/regress_index_expected

index c637541d6e658a08855f02bdc7dc8f515e2651ac..22e141758560f2ee4750683870fad0c30c430e42 100644 (file)
@@ -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);
+
index 012e422457d84bff9767e96e0d4bf5952d89e51f..ae75d050d1ea94010f4dc83d2ff715da6f88c6f0 100644 (file)
@@ -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)