1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-07 00:36:50 +03:00

Fixup some misusages of bms_num_members()

It's a bit inefficient to test if a Bitmapset is empty by counting all the
members and seeing if that number is zero. It's much better just to use
bms_is_empty().  Likewise for checking if there are at least two members,
just use bms_membership(), which does not need to do anything more after
finding two members.

Discussion: https://postgr.es/m/CAApHDvpvwm_QjbDOb5xga%2BKmX9XkN9xQavNGm3SvDbVnCYOerQ%40mail.gmail.com
Reviewed-by: Tomas Vondra
This commit is contained in:
David Rowley
2020-08-26 10:51:36 +12:00
parent ff60394a8c
commit c34605daed
2 changed files with 5 additions and 6 deletions

View File

@ -164,8 +164,7 @@ clauselist_selectivity_simple(PlannerInfo *root,
* directly to clause_selectivity(). None of what we might do below is
* relevant.
*/
if ((list_length(clauses) == 1) &&
bms_num_members(estimatedclauses) == 0)
if (list_length(clauses) == 1 && bms_is_empty(estimatedclauses))
return clause_selectivity(root, (Node *) linitial(clauses),
varRelid, jointype, sjinfo);