From e7752a5030bf1c6f3bb610b5436b663237b9a955 Mon Sep 17 00:00:00 2001 From: gentle_hu Date: Tue, 21 Dec 2021 20:14:19 +0800 Subject: [PATCH] fix issue where unique sql statistics are inaccurate --- src/common/backend/utils/cache/plancache.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/common/backend/utils/cache/plancache.cpp b/src/common/backend/utils/cache/plancache.cpp index 7cb66dda7..e36cb0dff 100644 --- a/src/common/backend/utils/cache/plancache.cpp +++ b/src/common/backend/utils/cache/plancache.cpp @@ -835,6 +835,13 @@ List* RevalidateCachedQuery(CachedPlanSource* plansource, bool has_lp) snapshot_set = true; } + /* + * Query Tree is about to be rebuilt, reset is_top_unique_sql, otherwise, unique sql id + * can not be set. + */ + if (IS_UNIQUE_SQL_TRACK_TOP) + SetIsTopUniqueSQL(false); + /* * Run parse analysis and rule rewriting. The parser tends to scribble on * its input, so we must copy the raw parse tree to prevent corruption of