Skip to content

Commit 6578234

Browse files
committed
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
1 parent feced13 commit 6578234

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

contrib/postgres_fdw/deparse.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1076,7 +1076,7 @@ deparseFromExpr(List *quals, deparse_expr_cxt *context)
10761076
/* Construct FROM clause */
10771077
appendStringInfoString(buf, " FROM ");
10781078
deparseFromExprForRel(buf, context->root, scanrel,
1079-
(bms_num_members(scanrel->relids) > 1),
1079+
(bms_membership(scanrel->relids) == BMS_MULTIPLE),
10801080
(Index) 0, NULL, context->params_list);
10811081

10821082
/* Construct WHERE clause */
@@ -1262,7 +1262,7 @@ deparseLockingClause(deparse_expr_cxt *context)
12621262
}
12631263

12641264
/* Add the relation alias if we are here for a join relation */
1265-
if (bms_num_members(rel->relids) > 1 &&
1265+
if (bms_membership(rel->relids) == BMS_MULTIPLE &&
12661266
rc->strength != LCS_NONE)
12671267
appendStringInfo(buf, " OF %s%d", REL_ALIAS_PREFIX, relid);
12681268
}
@@ -2328,7 +2328,7 @@ deparseVar(Var *node, deparse_expr_cxt *context)
23282328
int colno;
23292329

23302330
/* Qualify columns when multiple relations are involved. */
2331-
bool qualify_col = (bms_num_members(relids) > 1);
2331+
bool qualify_col = (bms_membership(relids) == BMS_MULTIPLE);
23322332

23332333
/*
23342334
* If the Var belongs to the foreign relation that is deparsed as a

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy