mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-16 22:50:13 +01:00
⚡ Reduce disk reads when editing documents https://github.com/siyuan-note/siyuan/issues/10961
This commit is contained in:
parent
b0fecae66e
commit
a5ec51a3d1
2 changed files with 25 additions and 24 deletions
|
|
@ -166,6 +166,10 @@ func initDBTables() {
|
|||
if nil != err {
|
||||
logging.LogFatalf(logging.ExitCodeReadOnlyDatabase, "create table [spans] failed: %s", err)
|
||||
}
|
||||
_, err = db.Exec("CREATE INDEX idx_spans_root_id ON spans(root_id)")
|
||||
if nil != err {
|
||||
logging.LogFatalf(logging.ExitCodeReadOnlyDatabase, "create index [idx_spans_root_id] failed: %s", err)
|
||||
}
|
||||
|
||||
_, err = db.Exec("DROP TABLE IF EXISTS assets")
|
||||
if nil != err {
|
||||
|
|
@ -175,6 +179,10 @@ func initDBTables() {
|
|||
if nil != err {
|
||||
logging.LogFatalf(logging.ExitCodeReadOnlyDatabase, "create table [assets] failed: %s", err)
|
||||
}
|
||||
_, err = db.Exec("CREATE INDEX idx_assets_root_id ON assets(root_id)")
|
||||
if nil != err {
|
||||
logging.LogFatalf(logging.ExitCodeReadOnlyDatabase, "create index [idx_assets_root_id] failed: %s", err)
|
||||
}
|
||||
|
||||
_, err = db.Exec("DROP TABLE IF EXISTS attributes")
|
||||
if nil != err {
|
||||
|
|
@ -184,6 +192,10 @@ func initDBTables() {
|
|||
if nil != err {
|
||||
logging.LogFatalf(logging.ExitCodeReadOnlyDatabase, "create table [attributes] failed: %s", err)
|
||||
}
|
||||
_, err = db.Exec("CREATE INDEX idx_attributes_root_id ON attributes(root_id)")
|
||||
if nil != err {
|
||||
logging.LogFatalf(logging.ExitCodeReadOnlyDatabase, "create index [idx_attributes_root_id] failed: %s", err)
|
||||
}
|
||||
|
||||
_, err = db.Exec("DROP TABLE IF EXISTS refs")
|
||||
if nil != err {
|
||||
|
|
@ -1008,12 +1020,6 @@ func deleteBlocksByBoxTx(tx *sql.Tx, box string) (err error) {
|
|||
return
|
||||
}
|
||||
|
||||
func deleteSpansByPathTx(tx *sql.Tx, box, path string) (err error) {
|
||||
stmt := "DELETE FROM spans WHERE box = ? AND path = ?"
|
||||
err = execStmtTx(tx, stmt, box, path)
|
||||
return
|
||||
}
|
||||
|
||||
func deleteSpansByRootID(tx *sql.Tx, rootID string) (err error) {
|
||||
stmt := "DELETE FROM spans WHERE root_id =?"
|
||||
err = execStmtTx(tx, stmt, rootID)
|
||||
|
|
@ -1026,21 +1032,9 @@ func deleteSpansByBoxTx(tx *sql.Tx, box string) (err error) {
|
|||
return
|
||||
}
|
||||
|
||||
func deleteAssetsByPathTx(tx *sql.Tx, box, path string) (err error) {
|
||||
stmt := "DELETE FROM assets WHERE box = ? AND docpath = ?"
|
||||
err = execStmtTx(tx, stmt, box, path)
|
||||
return
|
||||
}
|
||||
|
||||
func deleteAttributeByBlockID(tx *sql.Tx, blockID string) (err error) {
|
||||
stmt := "DELETE FROM attributes WHERE block_id = ?"
|
||||
err = execStmtTx(tx, stmt, blockID)
|
||||
return
|
||||
}
|
||||
|
||||
func deleteAttributesByPathTx(tx *sql.Tx, box, path string) (err error) {
|
||||
stmt := "DELETE FROM attributes WHERE box = ? AND path = ?"
|
||||
err = execStmtTx(tx, stmt, box, path)
|
||||
func deleteAssetsByRootID(tx *sql.Tx, rootID string) (err error) {
|
||||
stmt := "DELETE FROM assets WHERE root_id = ?"
|
||||
err = execStmtTx(tx, stmt, rootID)
|
||||
return
|
||||
}
|
||||
|
||||
|
|
@ -1050,6 +1044,13 @@ func deleteAssetsByBoxTx(tx *sql.Tx, box string) (err error) {
|
|||
return
|
||||
}
|
||||
|
||||
func deleteAttributesByRootID(tx *sql.Tx, rootID string) (err error) {
|
||||
stmt := "DELETE FROM attributes WHERE root_id = ?"
|
||||
err = execStmtTx(tx, stmt, rootID)
|
||||
return
|
||||
|
||||
}
|
||||
|
||||
func deleteAttributesByBoxTx(tx *sql.Tx, box string) (err error) {
|
||||
stmt := "DELETE FROM attributes WHERE box = ?"
|
||||
err = execStmtTx(tx, stmt, box)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue