mirror of
https://github.com/postgres/postgres.git
synced 2025-06-13 07:41:39 +03:00
Use optimized bitmap set function for membership test in postgres_fdw
Deparsing logic in postgres_fdw for locking, FROM clause (alias) and Var (column qualification) does not need to know the exact number of members involved, which can be calculated with bms_num_members(), but just if there is more than one relation involved, which is what bms_membership() does. The latter is more performant than the former so this shaves a couple of cycles. Author: Daniel Gustafsson Reviewed-by: Ashutosh Bapat, Nathan Bossart Discussion: https://postgr.es/m/C73594E0-2B67-4E10-BB35-CDE0E41CC384@yesql.se
This commit is contained in:
@ -1076,7 +1076,7 @@ deparseFromExpr(List *quals, deparse_expr_cxt *context)
|
|||||||
/* Construct FROM clause */
|
/* Construct FROM clause */
|
||||||
appendStringInfoString(buf, " FROM ");
|
appendStringInfoString(buf, " FROM ");
|
||||||
deparseFromExprForRel(buf, context->root, scanrel,
|
deparseFromExprForRel(buf, context->root, scanrel,
|
||||||
(bms_num_members(scanrel->relids) > 1),
|
(bms_membership(scanrel->relids) == BMS_MULTIPLE),
|
||||||
(Index) 0, NULL, context->params_list);
|
(Index) 0, NULL, context->params_list);
|
||||||
|
|
||||||
/* Construct WHERE clause */
|
/* Construct WHERE clause */
|
||||||
@ -1262,7 +1262,7 @@ deparseLockingClause(deparse_expr_cxt *context)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Add the relation alias if we are here for a join relation */
|
/* Add the relation alias if we are here for a join relation */
|
||||||
if (bms_num_members(rel->relids) > 1 &&
|
if (bms_membership(rel->relids) == BMS_MULTIPLE &&
|
||||||
rc->strength != LCS_NONE)
|
rc->strength != LCS_NONE)
|
||||||
appendStringInfo(buf, " OF %s%d", REL_ALIAS_PREFIX, relid);
|
appendStringInfo(buf, " OF %s%d", REL_ALIAS_PREFIX, relid);
|
||||||
}
|
}
|
||||||
@ -2328,7 +2328,7 @@ deparseVar(Var *node, deparse_expr_cxt *context)
|
|||||||
int colno;
|
int colno;
|
||||||
|
|
||||||
/* Qualify columns when multiple relations are involved. */
|
/* Qualify columns when multiple relations are involved. */
|
||||||
bool qualify_col = (bms_num_members(relids) > 1);
|
bool qualify_col = (bms_membership(relids) == BMS_MULTIPLE);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If the Var belongs to the foreign relation that is deparsed as a
|
* If the Var belongs to the foreign relation that is deparsed as a
|
||||||
|
Reference in New Issue
Block a user