summaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorTom Lane2000-02-15 20:49:31 +0000
committerTom Lane2000-02-15 20:49:31 +0000
commitb1577a7c78d2d8880b3c0f94689fb75bd074c897 (patch)
treec8d8f0500eb2eaa085d921a46a7d0987ba594a4a /src/test
parent553b5da6a1147881dc1df101ecf9bab75f767ccf (diff)
New cost model for planning, incorporating a penalty for random page
accesses versus sequential accesses, a (very crude) estimate of the effects of caching on random page accesses, and cost to evaluate WHERE- clause expressions. Export critical parameters for this model as SET variables. Also, create SET variables for the planner's enable flags (enable_seqscan, enable_indexscan, etc) so that these can be controlled more conveniently than via PGOPTIONS. Planner now estimates both startup cost (cost before retrieving first tuple) and total cost of each path, so it can optimize queries with LIMIT on a reasonable basis by interpolating between these costs. Same facility is a win for EXISTS(...) subqueries and some other cases. Redesign pathkey representation to achieve a major speedup in planning (I saw as much as 5X on a 10-way join); also minor changes in planner to reduce memory consumption by recycling discarded Path nodes and not constructing unnecessary lists. Minor cleanups to display more-plausible costs in some cases in EXPLAIN output. Initdb forced by change in interface to index cost estimation functions.
Diffstat (limited to 'src/test')
-rw-r--r--src/test/regress/expected/alter_table.out5
-rw-r--r--src/test/regress/expected/select.out3
-rw-r--r--src/test/regress/sql/alter_table.sql6
-rw-r--r--src/test/regress/sql/select.sql3
4 files changed, 13 insertions, 4 deletions
diff --git a/src/test/regress/expected/alter_table.out b/src/test/regress/expected/alter_table.out
index 53561ab33c8..174925df849 100644
--- a/src/test/regress/expected/alter_table.out
+++ b/src/test/regress/expected/alter_table.out
@@ -93,8 +93,11 @@ SELECT * FROM tmp;
DROP TABLE tmp;
--
-- rename -
--- should preserve indices
+-- should preserve indices, which we can check by seeing if a SELECT
+-- chooses an indexscan; however, in the absence of vacuum statistics
+-- it might not. Therefore, vacuum first.
--
+VACUUM ANALYZE tenk1;
ALTER TABLE tenk1 RENAME TO ten_k;
-- 20 values, sorted
SELECT unique1 FROM ten_k WHERE unique1 < 20;
diff --git a/src/test/regress/expected/select.out b/src/test/regress/expected/select.out
index d6953ab5a57..ed6cbac1df0 100644
--- a/src/test/regress/expected/select.out
+++ b/src/test/regress/expected/select.out
@@ -4,7 +4,8 @@
-- btree index
-- awk '{if($1<10){print;}else{next;}}' onek.data | sort +0n -1
--
-SELECT onek.* WHERE onek.unique1 < 10;
+SELECT onek.* WHERE onek.unique1 < 10
+ ORDER BY onek.unique1;
unique1 | unique2 | two | four | ten | twenty | hundred | thousand | twothousand | fivethous | tenthous | odd | even | stringu1 | stringu2 | string4
---------+---------+-----+------+-----+--------+---------+----------+-------------+-----------+----------+-----+------+----------+----------+---------
0 | 998 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | AAAAAA | KMBAAA | OOOOxx
diff --git a/src/test/regress/sql/alter_table.sql b/src/test/regress/sql/alter_table.sql
index bef443b9302..5ba66c46e8f 100644
--- a/src/test/regress/sql/alter_table.sql
+++ b/src/test/regress/sql/alter_table.sql
@@ -141,8 +141,12 @@ DROP TABLE tmp;
--
-- rename -
--- should preserve indices
+-- should preserve indices, which we can check by seeing if a SELECT
+-- chooses an indexscan; however, in the absence of vacuum statistics
+-- it might not. Therefore, vacuum first.
--
+VACUUM ANALYZE tenk1;
+
ALTER TABLE tenk1 RENAME TO ten_k;
-- 20 values, sorted
diff --git a/src/test/regress/sql/select.sql b/src/test/regress/sql/select.sql
index 3d5e66c98cd..42b664eaaee 100644
--- a/src/test/regress/sql/select.sql
+++ b/src/test/regress/sql/select.sql
@@ -5,7 +5,8 @@
-- btree index
-- awk '{if($1<10){print;}else{next;}}' onek.data | sort +0n -1
--
-SELECT onek.* WHERE onek.unique1 < 10;
+SELECT onek.* WHERE onek.unique1 < 10
+ ORDER BY onek.unique1;
--
-- awk '{if($1<20){print $1,$14;}else{next;}}' onek.data | sort +0nr -1