mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-16 22:50:13 +01:00
🎨 Manually optimize the data index to reduce space usage and improve performance https://github.com/siyuan-note/siyuan/issues/15663
This commit is contained in:
parent
8895613f8b
commit
34360fb9e3
15 changed files with 98 additions and 14 deletions
|
|
@ -664,7 +664,46 @@ func normalizeTree(tree *parse.Tree) (yfmRootID, yfmTitle, yfmUpdated string) {
|
|||
}
|
||||
|
||||
func VacuumDataIndex() {
|
||||
|
||||
util.PushEndlessProgress(Conf.language(270))
|
||||
defer util.PushClearProgress()
|
||||
|
||||
var oldsyDbSize, newSyDbSize, oldHistoryDbSize, newHistoryDbSize, oldAssetContentDbSize, newAssetContentDbSize int64
|
||||
info, _ := os.Stat(util.DBPath)
|
||||
if nil != info {
|
||||
oldsyDbSize = info.Size()
|
||||
}
|
||||
info, _ = os.Stat(util.HistoryDBPath)
|
||||
if nil != info {
|
||||
oldHistoryDbSize = info.Size()
|
||||
}
|
||||
info, _ = os.Stat(util.AssetContentDBPath)
|
||||
if nil != info {
|
||||
oldAssetContentDbSize = info.Size()
|
||||
}
|
||||
|
||||
sql.Vacuum()
|
||||
|
||||
info, _ = os.Stat(util.DBPath)
|
||||
if nil != info {
|
||||
newSyDbSize = info.Size()
|
||||
}
|
||||
info, _ = os.Stat(util.HistoryDBPath)
|
||||
if nil != info {
|
||||
newHistoryDbSize = info.Size()
|
||||
}
|
||||
info, _ = os.Stat(util.AssetContentDBPath)
|
||||
if nil != info {
|
||||
newAssetContentDbSize = info.Size()
|
||||
}
|
||||
|
||||
logging.LogInfof("vacuum database [siyuan.db: %s -> %s, history.db: %s -> %s, asset_content.db: %s -> %s]",
|
||||
humanize.BytesCustomCeil(uint64(oldsyDbSize), 2), humanize.BytesCustomCeil(uint64(newSyDbSize), 2),
|
||||
humanize.BytesCustomCeil(uint64(oldHistoryDbSize), 2), humanize.BytesCustomCeil(uint64(newHistoryDbSize), 2),
|
||||
humanize.BytesCustomCeil(uint64(oldAssetContentDbSize), 2), humanize.BytesCustomCeil(uint64(newAssetContentDbSize), 2))
|
||||
|
||||
releaseSize := (oldsyDbSize - newSyDbSize) + (oldHistoryDbSize - newHistoryDbSize) + (oldAssetContentDbSize - newAssetContentDbSize)
|
||||
msg := fmt.Sprintf(Conf.language(271), humanize.BytesCustomCeil(uint64(releaseSize), 2))
|
||||
util.PushMsg(msg, 7000)
|
||||
}
|
||||
|
||||
func FullReindex() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue