--- 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
DROP TABLE sample_queries;
DROP FUNCTION estimate_error(text, int);
+
+DROP FUNCTION qnodes(text);
+
+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)