mirror of
https://github.com/postgres/postgres.git
synced 2025-07-09 22:41:56 +03:00
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.
This commit is contained in:
@ -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;
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Reference in New Issue
Block a user