This is an automated email from the ASF dual-hosted git repository.

maxyang pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/cloudberry.git


The following commit(s) were added to refs/heads/main by this push:
     new 650a7311d5 Fix REFRESH fast path.
650a7311d5 is described below

commit 650a7311d578bb510a31c4ddc2c9761fdaac1254
Author: Zhang Mingli <[email protected]>
AuthorDate: Mon Oct 28 15:01:57 2024 +0800

    Fix REFRESH fast path.
    
    If a table is vacuum or clutered, we should not avoid
    REFRESH for mvs have it.
    Else, if it's a partition or partitioned now and later,
    we could not use it for Append Agg.
    
    Authored-by: Zhang Mingli [email protected]
---
 src/backend/catalog/gp_matview_aux.c | 13 +++++++++++++
 src/backend/commands/matview.c       |  2 +-
 src/include/catalog/gp_matview_aux.h |  2 ++
 3 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/src/backend/catalog/gp_matview_aux.c 
b/src/backend/catalog/gp_matview_aux.c
index 78216a40ca..cddba123d6 100644
--- a/src/backend/catalog/gp_matview_aux.c
+++ b/src/backend/catalog/gp_matview_aux.c
@@ -462,3 +462,16 @@ MatviewIsGeneralyUpToDate(Oid mvoid)
        return ((auxform->datastatus == MV_DATA_STATUS_UP_TO_DATE) || 
                        (auxform->datastatus == MV_DATA_STATUS_UP_REORGANIZED));
 }
+
+bool
+MatviewIsUpToDate(Oid mvoid)
+{
+       HeapTuple mvauxtup = SearchSysCacheCopy1(MVAUXOID, 
ObjectIdGetDatum(mvoid));
+
+       /* Not a candidate we recorded. */
+       if (!HeapTupleIsValid(mvauxtup))
+               return false;
+
+       Form_gp_matview_aux auxform = (Form_gp_matview_aux) GETSTRUCT(mvauxtup);
+       return (auxform->datastatus == MV_DATA_STATUS_UP_TO_DATE);
+}
diff --git a/src/backend/commands/matview.c b/src/backend/commands/matview.c
index 49cdce3b84..3d814f501e 100644
--- a/src/backend/commands/matview.c
+++ b/src/backend/commands/matview.c
@@ -482,7 +482,7 @@ ExecRefreshMatView(RefreshMatViewStmt *stmt, const char 
*queryString,
        if (gp_enable_refresh_fast_path &&
                !RelationIsIVM(matviewRel) &&
                !stmt->skipData &&
-               MatviewIsGeneralyUpToDate(matviewOid))
+               MatviewIsUpToDate(matviewOid))
        {
                table_close(matviewRel, NoLock);
 
diff --git a/src/include/catalog/gp_matview_aux.h 
b/src/include/catalog/gp_matview_aux.h
index 03f6a2300f..21e714075d 100644
--- a/src/include/catalog/gp_matview_aux.h
+++ b/src/include/catalog/gp_matview_aux.h
@@ -67,4 +67,6 @@ extern bool MatviewUsableForAppendAgg(Oid mvoid);
 
 extern bool MatviewIsGeneralyUpToDate(Oid mvoid);
 
+extern bool MatviewIsUpToDate(Oid mvoid);
+
 #endif                 /* GP_MATVIEW_AUX_H */


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to