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

Commitc34605d

Browse files
committed
Fixup some misusages of bms_num_members()
It's a bit inefficient to test if a Bitmapset is empty by counting all themembers and seeing if that number is zero. It's much better just to usebms_is_empty(). Likewise for checking if there are at least two members,just use bms_membership(), which does not need to do anything more afterfinding two members.Discussion:https://postgr.es/m/CAApHDvpvwm_QjbDOb5xga%2BKmX9XkN9xQavNGm3SvDbVnCYOerQ%40mail.gmail.comReviewed-by: Tomas Vondra
1 parentff60394 commitc34605d

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

‎src/backend/optimizer/path/clausesel.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,7 @@ clauselist_selectivity_simple(PlannerInfo *root,
164164
* directly to clause_selectivity(). None of what we might do below is
165165
* relevant.
166166
*/
167-
if ((list_length(clauses)==1)&&
168-
bms_num_members(estimatedclauses)==0)
167+
if (list_length(clauses)==1&&bms_is_empty(estimatedclauses))
169168
returnclause_selectivity(root, (Node*)linitial(clauses),
170169
varRelid,jointype,sjinfo);
171170

‎src/backend/statistics/dependencies.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1246,7 +1246,7 @@ dependencies_clauselist_selectivity(PlannerInfo *root,
12461246
* of clauses. We must return 1.0 so the calling function's selectivity is
12471247
* unaffected.
12481248
*/
1249-
if (bms_num_members(clauses_attnums)<2)
1249+
if (bms_membership(clauses_attnums)!=BMS_MULTIPLE)
12501250
{
12511251
bms_free(clauses_attnums);
12521252
pfree(list_attnums);
@@ -1273,18 +1273,18 @@ dependencies_clauselist_selectivity(PlannerInfo *root,
12731273
{
12741274
StatisticExtInfo*stat= (StatisticExtInfo*)lfirst(l);
12751275
Bitmapset*matched;
1276-
intnum_matched;
1276+
BMS_Membershipmembership;
12771277

12781278
/* skip statistics that are not of the correct type */
12791279
if (stat->kind!=STATS_EXT_DEPENDENCIES)
12801280
continue;
12811281

12821282
matched=bms_intersect(clauses_attnums,stat->keys);
1283-
num_matched=bms_num_members(matched);
1283+
membership=bms_membership(matched);
12841284
bms_free(matched);
12851285

12861286
/* skip objects matching fewer than two attributes from clauses */
1287-
if (num_matched<2)
1287+
if (membership!=BMS_MULTIPLE)
12881288
continue;
12891289

12901290
func_dependencies[nfunc_dependencies]

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp