diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2009-07-27 00:26:03 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2009-07-27 00:26:03 +0000 |
commit | 8835d63b273486375b53d2b7686c55d88cbf456e (patch) | |
tree | 6a32ed2ac823418e66d04b3cd74877af91fdcb1a /src | |
parent | d4382c4ae7ea1e272f4fee388aac8ff99421471a (diff) | |
download | postgresql-8835d63b273486375b53d2b7686c55d88cbf456e.tar.gz postgresql-8835d63b273486375b53d2b7686c55d88cbf456e.zip |
Experiment with using EXPLAIN COSTS OFF in regression tests.
This is a simple test to see whether COSTS OFF will help much with getting
EXPLAIN output that's sufficiently platform-independent for use in the
regression tests. The planner does have some freedom of choice in these
examples (plain via bitmap indexscan), so I'm not sure what will happen.
Diffstat (limited to 'src')
-rw-r--r-- | src/test/regress/expected/create_index.out | 83 | ||||
-rw-r--r-- | src/test/regress/sql/create_index.sql | 21 |
2 files changed, 98 insertions, 6 deletions
diff --git a/src/test/regress/expected/create_index.out b/src/test/regress/expected/create_index.out index e43ee6aa53d..7b37cbf40bc 100644 --- a/src/test/regress/expected/create_index.out +++ b/src/test/regress/expected/create_index.out @@ -113,9 +113,20 @@ SELECT count(*) FROM gcircle_tbl WHERE f1 && '<(500,500),500>'::circle; SET enable_seqscan = OFF; SET enable_indexscan = ON; SET enable_bitmapscan = ON; --- there's no easy way to check that these commands actually use --- the index, unfortunately. (EXPLAIN would work, but its output --- changes too often for me to want to put an EXPLAIN in the test...) +EXPLAIN (COSTS OFF) +SELECT * FROM fast_emp4000 + WHERE home_base @ '(200,200),(2000,1000)'::box + ORDER BY (home_base[0])[0]; + QUERY PLAN +---------------------------------------------------------------------- + Sort + Sort Key: ((home_base[0])[0]) + -> Bitmap Heap Scan on fast_emp4000 + Recheck Cond: (home_base @ '(2000,1000),(200,200)'::box) + -> Bitmap Index Scan on grect2ind + Index Cond: (home_base @ '(2000,1000),(200,200)'::box) +(6 rows) + SELECT * FROM fast_emp4000 WHERE home_base @ '(200,200),(2000,1000)'::box ORDER BY (home_base[0])[0]; @@ -125,18 +136,51 @@ SELECT * FROM fast_emp4000 (1444,403),(1346,344) (2 rows) +EXPLAIN (COSTS OFF) +SELECT count(*) FROM fast_emp4000 WHERE home_base && '(1000,1000,0,0)'::box; + QUERY PLAN +------------------------------------------------------------------- + Aggregate + -> Bitmap Heap Scan on fast_emp4000 + Recheck Cond: (home_base && '(1000,1000),(0,0)'::box) + -> Bitmap Index Scan on grect2ind + Index Cond: (home_base && '(1000,1000),(0,0)'::box) +(5 rows) + SELECT count(*) FROM fast_emp4000 WHERE home_base && '(1000,1000,0,0)'::box; count ------- 2 (1 row) +EXPLAIN (COSTS OFF) +SELECT count(*) FROM fast_emp4000 WHERE home_base IS NULL; + QUERY PLAN +----------------------------------------------- + Aggregate + -> Bitmap Heap Scan on fast_emp4000 + Recheck Cond: (home_base IS NULL) + -> Bitmap Index Scan on grect2ind + Index Cond: (home_base IS NULL) +(5 rows) + SELECT count(*) FROM fast_emp4000 WHERE home_base IS NULL; count ------- 278 (1 row) +EXPLAIN (COSTS OFF) +SELECT * FROM polygon_tbl WHERE f1 ~ '((1,1),(2,2),(2,1))'::polygon + ORDER BY (poly_center(f1))[0]; + QUERY PLAN +----------------------------------------------------------- + Sort + Sort Key: ((poly_center(f1))[0]) + -> Index Scan using gpolygonind on polygon_tbl + Index Cond: (f1 ~ '((1,1),(2,2),(2,1))'::polygon) +(4 rows) + SELECT * FROM polygon_tbl WHERE f1 ~ '((1,1),(2,2),(2,1))'::polygon ORDER BY (poly_center(f1))[0]; f1 @@ -144,6 +188,17 @@ SELECT * FROM polygon_tbl WHERE f1 ~ '((1,1),(2,2),(2,1))'::polygon ((2,0),(2,4),(0,0)) (1 row) +EXPLAIN (COSTS OFF) +SELECT * FROM circle_tbl WHERE f1 && circle(point(1,-2), 1) + ORDER BY area(f1); + QUERY PLAN +-------------------------------------------------- + Sort + Sort Key: (area(f1)) + -> Index Scan using gcircleind on circle_tbl + Index Cond: (f1 && '<(1,-2),1>'::circle) +(4 rows) + SELECT * FROM circle_tbl WHERE f1 && circle(point(1,-2), 1) ORDER BY area(f1); f1 @@ -154,12 +209,34 @@ SELECT * FROM circle_tbl WHERE f1 && circle(point(1,-2), 1) <(100,1),115> (4 rows) +EXPLAIN (COSTS OFF) +SELECT count(*) FROM gpolygon_tbl WHERE f1 && '(1000,1000,0,0)'::polygon; + QUERY PLAN +------------------------------------------------------------------ + Aggregate + -> Bitmap Heap Scan on gpolygon_tbl + Recheck Cond: (f1 && '((1000,1000),(0,0))'::polygon) + -> Bitmap Index Scan on ggpolygonind + Index Cond: (f1 && '((1000,1000),(0,0))'::polygon) +(5 rows) + SELECT count(*) FROM gpolygon_tbl WHERE f1 && '(1000,1000,0,0)'::polygon; count ------- 2 (1 row) +EXPLAIN (COSTS OFF) +SELECT count(*) FROM gcircle_tbl WHERE f1 && '<(500,500),500>'::circle; + QUERY PLAN +------------------------------------------------------------- + Aggregate + -> Bitmap Heap Scan on gcircle_tbl + Recheck Cond: (f1 && '<(500,500),500>'::circle) + -> Bitmap Index Scan on ggcircleind + Index Cond: (f1 && '<(500,500),500>'::circle) +(5 rows) + SELECT count(*) FROM gcircle_tbl WHERE f1 && '<(500,500),500>'::circle; count ------- diff --git a/src/test/regress/sql/create_index.sql b/src/test/regress/sql/create_index.sql index 9638b23312e..66ab0f9f02f 100644 --- a/src/test/regress/sql/create_index.sql +++ b/src/test/regress/sql/create_index.sql @@ -112,25 +112,40 @@ SET enable_seqscan = OFF; SET enable_indexscan = ON; SET enable_bitmapscan = ON; --- there's no easy way to check that these commands actually use --- the index, unfortunately. (EXPLAIN would work, but its output --- changes too often for me to want to put an EXPLAIN in the test...) +EXPLAIN (COSTS OFF) +SELECT * FROM fast_emp4000 + WHERE home_base @ '(200,200),(2000,1000)'::box + ORDER BY (home_base[0])[0]; SELECT * FROM fast_emp4000 WHERE home_base @ '(200,200),(2000,1000)'::box ORDER BY (home_base[0])[0]; +EXPLAIN (COSTS OFF) +SELECT count(*) FROM fast_emp4000 WHERE home_base && '(1000,1000,0,0)'::box; SELECT count(*) FROM fast_emp4000 WHERE home_base && '(1000,1000,0,0)'::box; +EXPLAIN (COSTS OFF) +SELECT count(*) FROM fast_emp4000 WHERE home_base IS NULL; SELECT count(*) FROM fast_emp4000 WHERE home_base IS NULL; +EXPLAIN (COSTS OFF) +SELECT * FROM polygon_tbl WHERE f1 ~ '((1,1),(2,2),(2,1))'::polygon + ORDER BY (poly_center(f1))[0]; SELECT * FROM polygon_tbl WHERE f1 ~ '((1,1),(2,2),(2,1))'::polygon ORDER BY (poly_center(f1))[0]; +EXPLAIN (COSTS OFF) +SELECT * FROM circle_tbl WHERE f1 && circle(point(1,-2), 1) + ORDER BY area(f1); SELECT * FROM circle_tbl WHERE f1 && circle(point(1,-2), 1) ORDER BY area(f1); +EXPLAIN (COSTS OFF) +SELECT count(*) FROM gpolygon_tbl WHERE f1 && '(1000,1000,0,0)'::polygon; SELECT count(*) FROM gpolygon_tbl WHERE f1 && '(1000,1000,0,0)'::polygon; +EXPLAIN (COSTS OFF) +SELECT count(*) FROM gcircle_tbl WHERE f1 && '<(500,500),500>'::circle; SELECT count(*) FROM gcircle_tbl WHERE f1 && '<(500,500),500>'::circle; RESET enable_seqscan; |