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

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

commit e350680dfdef5d82ff5764bd79e98d342d4ff375
Author: zhangwenchao <[email protected]>
AuthorDate: Tue Oct 28 14:37:24 2025 +0800

    Fix orca judgement of whether relation is empty is not accurate.
    
    When retrieve RelStats, orca use reltuples is whether -1 to decide
    relation is empty. However, reltuples 0 also means relation is
    empty.
    
    Authored-by: Zhang Wenchao <[email protected]>
---
 src/backend/gpopt/translate/CTranslatorRelcacheToDXL.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/backend/gpopt/translate/CTranslatorRelcacheToDXL.cpp 
b/src/backend/gpopt/translate/CTranslatorRelcacheToDXL.cpp
index d8e1da28f0d..6a5d679a11f 100644
--- a/src/backend/gpopt/translate/CTranslatorRelcacheToDXL.cpp
+++ b/src/backend/gpopt/translate/CTranslatorRelcacheToDXL.cpp
@@ -1836,7 +1836,7 @@ CTranslatorRelcacheToDXL::RetrieveRelStats(CMemoryPool 
*mp, IMDId *mdid)
         * count of the partition table is -1.
         */
        BOOL relation_empty = false;
-       if (num_rows == -1.0)
+       if (num_rows == -1.0 || num_rows == 0.0)
        {
                relation_empty = true;
        }


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

Reply via email to