mirror of
https://github.com/Syngnat/GoNavi.git
synced 2026-08-19 22:15:12 +08:00
🐛 fix(sqlite): 修复表概览行数与大小统计
- 通过 driver-agent 为 SQLite 表列表补充精确行数与存储占用 - 使用 dbstat 区分数据页和索引页并支持相对大小展示 - 区分未知统计与真实零值并补充前后端回归测试
This commit is contained in:
@@ -1964,6 +1964,14 @@ func (a *App) DBGetTables(config connection.ConnectionConfig, dbName string) con
|
||||
logger.Warnf("DBGetTables 获取表行数失败(保留已获取的表列表):%s err=%v", formatConnSummary(runConfig), countErr)
|
||||
}
|
||||
}
|
||||
tableStorageStats := map[string]db.TableStorageStats{}
|
||||
if storageProvider, ok := dbInst.(db.TableStorageStatsProvider); ok {
|
||||
var storageErr error
|
||||
tableStorageStats, storageErr = storageProvider.GetTableStorageStats(dbName, tables)
|
||||
if storageErr != nil {
|
||||
logger.Warnf("DBGetTables 获取表存储大小失败(保留已获取的表列表):%s err=%v", formatConnSummary(runConfig), storageErr)
|
||||
}
|
||||
}
|
||||
|
||||
resData := make([]map[string]string, 0, len(tables))
|
||||
for _, name := range tables {
|
||||
@@ -1971,6 +1979,10 @@ func (a *App) DBGetTables(config connection.ConnectionConfig, dbName string) con
|
||||
if rowCount, ok := tableRowCounts[name]; ok {
|
||||
item["Rows"] = strconv.FormatInt(rowCount, 10)
|
||||
}
|
||||
if storageStats, ok := tableStorageStats[name]; ok {
|
||||
item["Data_length"] = strconv.FormatInt(storageStats.DataLength, 10)
|
||||
item["Index_length"] = strconv.FormatInt(storageStats.IndexLength, 10)
|
||||
}
|
||||
resData = append(resData, item)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user