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

Commit3b45944

Browse files
committed
Remove unnecessary code in dependency_is_compatible_expression().
Scanning the expression for compatible Vars isn't really necessary,because the subsequent match against StatisticExtInfo entries willeliminate expressions containing other Vars just fine. Moreover,this code hadn't stopped to think about what to do withPlaceHolderVars or Aggrefs in the clause; and at least for the PHVcase, that demonstrably leads to failures. Rather than work outwhether it's reasonable to ignore those, let's just remove thewhole stanza.Per report from Richard Guo. Back-patch to v14 where this codewas added.Discussion:https://postgr.es/m/CAMbWs48Mmvm-acGevXuwpB=g5JMqVSL6i9z5UaJyLGJqa-XPAA@mail.gmail.com
1 parent74a1a36 commit3b45944

File tree

1 file changed

+3
-25
lines changed

1 file changed

+3
-25
lines changed

‎src/backend/statistics/dependencies.c

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1163,13 +1163,12 @@ clauselist_apply_dependencies(PlannerInfo *root, List *clauses,
11631163
*Determines if the expression is compatible with functional dependencies
11641164
*
11651165
* Similar to dependency_is_compatible_clause, but doesn't enforce that the
1166-
* expression is a simple Var.OTOH we check that there's at least one
1167-
*statistics object matching the expression.
1166+
* expression is a simple Var. On success, return the matching statistics
1167+
*expression into *expr.
11681168
*/
11691169
staticbool
11701170
dependency_is_compatible_expression(Node*clause,Indexrelid,List*statlist,Node**expr)
11711171
{
1172-
List*vars;
11731172
ListCell*lc,
11741173
*lc2;
11751174
Node*clause_expr;
@@ -1317,29 +1316,8 @@ dependency_is_compatible_expression(Node *clause, Index relid, List *statlist, N
13171316
if (IsA(clause_expr,RelabelType))
13181317
clause_expr= (Node*) ((RelabelType*)clause_expr)->arg;
13191318

1320-
vars=pull_var_clause(clause_expr,0);
1321-
1322-
foreach(lc,vars)
1323-
{
1324-
Var*var= (Var*)lfirst(lc);
1325-
1326-
/* Ensure Var is from the correct relation */
1327-
if (var->varno!=relid)
1328-
return false;
1329-
1330-
/* We also better ensure the Var is from the current level */
1331-
if (var->varlevelsup!=0)
1332-
return false;
1333-
1334-
/* Also ignore system attributes (we don't allow stats on those) */
1335-
if (!AttrNumberIsForUserDefinedAttr(var->varattno))
1336-
return false;
1337-
}
1338-
13391319
/*
1340-
* Check if we actually have a matching statistics for the expression.
1341-
*
1342-
* XXX Maybe this is an overkill. We'll eliminate the expressions later.
1320+
* Search for a matching statistics expression.
13431321
*/
13441322
foreach(lc,statlist)
13451323
{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp