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

Commit7a80e38

Browse files
committed
Skip useless calculation of join RTE column names during EXPLAIN.
There's no need for set_simple_column_names() to compute uniquecolumn names for join RTEs, because a finished plan tree willnot contain any join alias Vars that we could need names for.Its other, internal callers will not pass it any join RTEsanyway, so the upshot is we can just skip join RTEs here.Aside from getting rid of a klugy against-its-documentation use ofset_relation_column_names, this can speed up EXPLAIN substantiallywhen considering many-join queries, because the upper join RTEstend to have a lot of columns.Sami Imseih, with cosmetic changes by meDiscussion:https://postgr.es/m/CAA5RZ0th3q-0p1pri58z9grG8r8azmEBa8o1rtkwhLmJg_cH+g@mail.gmail.com
1 parentdc6acfd commit7a80e38

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

‎src/backend/utils/adt/ruleutils.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3773,9 +3773,8 @@ deparse_context_for_plan_tree(PlannedStmt *pstmt, List *rtable_names)
37733773
dpns->appendrels=NULL;/* don't need it */
37743774

37753775
/*
3776-
* Set up column name aliases. We will get rather bogus results for join
3777-
* RTEs, but that doesn't matter because plan trees don't contain any join
3778-
* alias Vars.
3776+
* Set up column name aliases, ignoring any join RTEs; they don't matter
3777+
* because plan trees don't contain any join alias Vars.
37793778
*/
37803779
set_simple_column_names(dpns);
37813780

@@ -4067,8 +4066,10 @@ set_deparse_for_query(deparse_namespace *dpns, Query *query,
40674066
*
40684067
* This handles EXPLAIN and cases where we only have relation RTEs. Without
40694068
* a join tree, we can't do anything smart about join RTEs, but we don't
4070-
* need to (note that EXPLAIN should never see join alias Vars anyway).
4071-
* If we do hit a join RTE we'll just process it like a non-table base RTE.
4069+
* need to, because EXPLAIN should never see join alias Vars anyway.
4070+
* If we find a join RTE we'll just skip it, leaving its deparse_columns
4071+
* struct all-zero. If somehow we try to deparse a join alias Var, we'll
4072+
* error out cleanly because the struct's num_cols will be zero.
40724073
*/
40734074
staticvoid
40744075
set_simple_column_names(deparse_namespace*dpns)
@@ -4082,13 +4083,14 @@ set_simple_column_names(deparse_namespace *dpns)
40824083
dpns->rtable_columns=lappend(dpns->rtable_columns,
40834084
palloc0(sizeof(deparse_columns)));
40844085

4085-
/* Assign unique column aliases within each RTE */
4086+
/* Assign unique column aliases within eachnon-joinRTE */
40864087
forboth(lc,dpns->rtable,lc2,dpns->rtable_columns)
40874088
{
40884089
RangeTblEntry*rte= (RangeTblEntry*)lfirst(lc);
40894090
deparse_columns*colinfo= (deparse_columns*)lfirst(lc2);
40904091

4091-
set_relation_column_names(dpns,rte,colinfo);
4092+
if (rte->rtekind!=RTE_JOIN)
4093+
set_relation_column_names(dpns,rte,colinfo);
40924094
}
40934095
}
40944096

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp