profile-patch-for-patched.txt
text/plain
Filename: profile-patch-for-patched.txt
Type: text/plain
Part: 3
diff --git a/src/backend/nodes/bitmapset.c b/src/backend/nodes/bitmapset.c
index 9cda3b1cc1..95180e6bca 100644
--- a/src/backend/nodes/bitmapset.c
+++ b/src/backend/nodes/bitmapset.c
@@ -90,6 +90,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? or both NULL?
*/
@@ -98,6 +108,20 @@ bms_equal(const Bitmapset *a, const Bitmapset *b)
{
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)
{
@@ -112,6 +136,8 @@ bms_equal(const Bitmapset *a, const Bitmapset *b)
if (a->nwords != b->nwords)
return false;
+ loops++;
+
/* check each word matches */
i = 0;
do
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);