@@ -929,17 +929,27 @@ func (m *Meta) IterTables(dbID int64, fn func(info *model.TableInfo) error) erro
929
929
return errors .Trace (err )
930
930
}
931
931
932
- // ListTables shows all tables in database.
933
- func (m * Meta ) ListTables (dbID int64 ) ([]* model.TableInfo , error ) {
932
+ // GetMetasByDBID return all meta information of a database.
933
+ // Note(dongmen): This method is used by TiCDC to reduce the time of changefeed initialization.
934
+ // Ref: https://github.com/pingcap/tiflow/issues/11109
935
+ func (m * Meta ) GetMetasByDBID (dbID int64 ) ([]structure.HashPair , error ) {
934
936
dbKey := m .dbKey (dbID )
935
937
if err := m .checkDBExists (dbKey ); err != nil {
936
938
return nil , errors .Trace (err )
937
939
}
938
-
939
940
res , err := m .txn .HGetAll (dbKey )
940
941
if err != nil {
941
942
return nil , errors .Trace (err )
942
943
}
944
+ return res , nil
945
+ }
946
+
947
+ // ListTables shows all tables in database.
948
+ func (m * Meta ) ListTables (dbID int64 ) ([]* model.TableInfo , error ) {
949
+ res , err := m .GetMetasByDBID (dbID )
950
+ if err != nil {
951
+ return nil , errors .Trace (err )
952
+ }
943
953
944
954
tables := make ([]* model.TableInfo , 0 , len (res )/ 2 )
945
955
for _ , r := range res {
@@ -963,12 +973,7 @@ func (m *Meta) ListTables(dbID int64) ([]*model.TableInfo, error) {
963
973
964
974
// ListSimpleTables shows all simple tables in database.
965
975
func (m * Meta ) ListSimpleTables (dbID int64 ) ([]* model.TableNameInfo , error ) {
966
- dbKey := m .dbKey (dbID )
967
- if err := m .checkDBExists (dbKey ); err != nil {
968
- return nil , errors .Trace (err )
969
- }
970
-
971
- res , err := m .txn .HGetAll (dbKey )
976
+ res , err := m .GetMetasByDBID (dbID )
972
977
if err != nil {
973
978
return nil , errors .Trace (err )
974
979
}
0 commit comments