diff --git a/src/backend/nodes/bitmapset.c b/src/backend/nodes/bitmapset.c index 7ba3cf635b..cd3ec14cd0 100644 --- a/src/backend/nodes/bitmapset.c +++ b/src/backend/nodes/bitmapset.c @@ -84,6 +84,16 @@ bms_copy(const Bitmapset *a) return result; } +static long long total = 0; +static long long loops = 0; + +void +print_profile(void) +{ + elog(LOG, "[bms_equal] Total %lld calls, %lld loops executed", + total, loops); +} + /* * bms_equal - are two bitmapsets equal? * @@ -99,6 +109,20 @@ bms_equal(const Bitmapset *a, const Bitmapset *b) int longlen; int i; + total++; + if (total % 100000 == 0) + { + /* + * Print what we are comparing. We prevent too many logs by logging + * only when total % 100000 == 0. + */ + char *a_str = nodeToString(a); + char *b_str = nodeToString(b); + elog(LOG, "[bms_equal] Comparing %s and %s", a_str, b_str); + pfree(a_str); + pfree(b_str); + } + /* Handle cases where either input is NULL */ if (a == NULL) { @@ -108,6 +132,7 @@ bms_equal(const Bitmapset *a, const Bitmapset *b) } else if (b == NULL) return false; + loops++; /* Identify shorter and longer input */ if (a->nwords <= b->nwords) { diff --git a/src/backend/optimizer/plan/planner.c b/src/backend/optimizer/plan/planner.c index 1e4dd27dba..d0c90ef0cf 100644 --- a/src/backend/optimizer/plan/planner.c +++ b/src/backend/optimizer/plan/planner.c @@ -279,6 +279,7 @@ planner(Query *parse, const char *query_string, int cursorOptions, result = (*planner_hook) (parse, query_string, cursorOptions, boundParams); else result = standard_planner(parse, query_string, cursorOptions, boundParams); + print_profile(); return result; } diff --git a/src/include/nodes/bitmapset.h b/src/include/nodes/bitmapset.h index 14de6a9ff1..a28b3a77b0 100644 --- a/src/include/nodes/bitmapset.h +++ b/src/include/nodes/bitmapset.h @@ -79,6 +79,7 @@ typedef enum */ extern Bitmapset *bms_copy(const Bitmapset *a); +extern void print_profile(void); extern bool bms_equal(const Bitmapset *a, const Bitmapset *b); extern int bms_compare(const Bitmapset *a, const Bitmapset *b); extern Bitmapset *bms_make_singleton(int x);