Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd158fce

Browse files
committed
Add optimizer README file.
1 parent542d4e5 commitd158fce

File tree

1 file changed

+66
-0
lines changed

1 file changed

+66
-0
lines changed

‎src/backend/optimizer/README

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
Thse directories take the Query structure returned by the parser, and
2+
generate a plan used by the executor. The /plan directory generates the
3+
plan, the /path generates all possible ways to join the tables, and
4+
/prep handles special cases like inheritance. /utils is utility stuff.
5+
6+
planner()
7+
handle inheritance by processing separately
8+
-init_query_planner()
9+
preprocess target list
10+
preprocess qualifications(WHERE)
11+
--query_planner()
12+
pull out constants from target list
13+
get a target list that only contains column names, no expressions
14+
if none, then return
15+
---subplanner()
16+
make list of relations in target
17+
make list of relations in where clause
18+
find which relations can do merge sort and hash joins
19+
----find_paths()
20+
find scan and all index paths for each relation not yet joined
21+
one relation, return
22+
find selectivity of columns used in joins
23+
-----find_join_paths()
24+
Summary: With OPTIMIZER_DEBUG defined, you see:
25+
26+
Tables 1, 2, 3, and 4 are joined as:
27+
{1 2},{1 3},{1 4},{2 3},{2 4}
28+
{1 2 3},{1 2 4},{2 3 4}
29+
{1 2 3 4}
30+
31+
Actual output tests show combinations:
32+
{4 2},{3 2},{1 4},{1 3},{1 2}
33+
{4 2 3},{1 4 2},{1 3 2}
34+
{4 2 3 1}
35+
36+
Cheapest join order shows:
37+
{4 2},{3 2},{1 4},{1 3},{1 2}
38+
{3 2 4},{1 4 2},{1 3 2}
39+
{1 4 2 3}
40+
41+
It first finds the best way to join each table to every other
42+
table. It then takes those joined table combinations, and joins
43+
them to the other joined table combinations, until all tables are
44+
joined.
45+
46+
jump to geqo if needed
47+
again:
48+
find_join_rels():
49+
for each joinrel:
50+
find_clause_joins()
51+
for each join on joinrel:
52+
if a join from the join clause adds only one relation, do the join
53+
or find_clauseless_joins()
54+
find_all_join_paths()
55+
generate paths(nested,mergesort) for joins found in find_join_rels()
56+
prune_joinrels()
57+
remove from the join list the relation we just added to each join
58+
prune_rel_paths()
59+
set cheapest and perhaps remove unordered path, recompute table sizes
60+
if we have not done all the tables, go to "again"
61+
do group(GROUP)
62+
do aggregate
63+
put back constants
64+
re-flatten target list
65+
make unique(DISTINCT)
66+
make sort(ORDER BY)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp