diff --git a/src/gausskernel/optimizer/commands/verify.cpp b/src/gausskernel/optimizer/commands/verify.cpp index 55597a8cb..e745f007e 100644 --- a/src/gausskernel/optimizer/commands/verify.cpp +++ b/src/gausskernel/optimizer/commands/verify.cpp @@ -873,7 +873,12 @@ static void DoVerifyIndexRel(VacuumStmt* stmt, Oid indexRelid) { Oid heapOid = IndexGetRelation(indexRelid, false); Relation heapRel = heap_open(heapOid, AccessShareLock); - if (RelationIsPartitioned(heapRel)) { + Relation indexRel = index_open(indexRelid, AccessShareLock); + if (!RelationIsPartitioned(heapRel) || RelationIsGlobalIndex(indexRel)) { + VerifyIndexRel(stmt, indexRel); + index_close(indexRel, AccessShareLock); + } else { + index_close(indexRel, AccessShareLock); Partition part; Relation partRel; ListCell* cell = NULL; @@ -891,10 +896,6 @@ static void DoVerifyIndexRel(VacuumStmt* stmt, Oid indexRelid) partitionClose(heapRel, part, AccessShareLock); releaseDummyRelation(&partRel); } - } else { - Relation indexRel = index_open(indexRelid, AccessShareLock); - VerifyIndexRel(stmt, indexRel); - index_close(indexRel, AccessShareLock); } heap_close(heapRel, AccessShareLock); @@ -969,6 +970,13 @@ static void VerifyPartIndexRels(VacuumStmt* stmt, Relation rel, Relation partiti indexIds = RelationGetIndexList(rel); foreach (indexId, indexIds) { Oid indexOid = lfirst_oid(indexId); + Relation indexRel = index_open(indexOid, AccessShareLock); + if (RelationIsGlobalIndex(indexRel)) { + VerifyIndexRel(stmt, indexRel); + index_close(indexRel, AccessShareLock); + continue; + } + index_close(indexRel, AccessShareLock); VerifyPartIndexRel(stmt, rel, partitionRel, indexOid); } return; diff --git a/src/test/regress/expected/gpi_range.out b/src/test/regress/expected/gpi_range.out index 193dcef1c..f6d25db93 100644 --- a/src/test/regress/expected/gpi_range.out +++ b/src/test/regress/expected/gpi_range.out @@ -114,6 +114,9 @@ select count(*) from gpi_range_table where INV_WAREHOUSE_SK < 10000; 9999 (1 row) +analyze verify fast local_gpi_range_table_index1; +analyze verify fast global_gpi_range_table_index1; +analyze verify fast global_gpi_range_table_index2; --clean drop index if exists local_gpi_range_table_index1; drop index if exists global_gpi_range_table_index1; diff --git a/src/test/regress/sql/gpi_range.sql b/src/test/regress/sql/gpi_range.sql index 27b25f2b4..95a47c6b2 100644 --- a/src/test/regress/sql/gpi_range.sql +++ b/src/test/regress/sql/gpi_range.sql @@ -53,6 +53,10 @@ select count(*) from gpi_range_table where INV_ITEM_SK < 10000; explain (costs off) select count(*) from gpi_range_table where INV_WAREHOUSE_SK < 10000; select count(*) from gpi_range_table where INV_WAREHOUSE_SK < 10000; +analyze verify fast local_gpi_range_table_index1; +analyze verify fast global_gpi_range_table_index1; +analyze verify fast global_gpi_range_table_index2; + --clean drop index if exists local_gpi_range_table_index1; drop index if exists global_gpi_range_table_index1;