🐛 fix(sqlite): 修复表概览行数与大小统计

- 通过 driver-agent 为 SQLite 表列表补充精确行数与存储占用
- 使用 dbstat 区分数据页和索引页并支持相对大小展示
- 区分未知统计与真实零值并补充前后端回归测试
This commit is contained in:
AutumnNazi
2026-07-16 12:44:18 +08:00
parent 695fad283c
commit 2400823ca4
6 changed files with 233 additions and 19 deletions

View File

@@ -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)
}