mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-16 22:50:13 +01:00
⚡ Improve data indexing performance https://github.com/siyuan-note/siyuan/issues/16397
Signed-off-by: Daniel <845765@qq.com>
This commit is contained in:
parent
bcef9bdff9
commit
8429a1df0b
3 changed files with 67 additions and 2 deletions
|
|
@ -410,6 +410,18 @@ func RemoveBlockTreesByRootID(rootID string) {
|
|||
}
|
||||
}
|
||||
|
||||
func CountBlockTreesByPathPrefix(pathPrefix string) (ret int) {
|
||||
sqlStmt := "SELECT COUNT(*) FROM blocktrees WHERE path LIKE ?"
|
||||
err := db.QueryRow(sqlStmt, pathPrefix+"%").Scan(&ret)
|
||||
if err != nil {
|
||||
if errors.Is(err, sql.ErrNoRows) {
|
||||
return 0
|
||||
}
|
||||
logging.LogErrorf("sql query [%s] failed: %s", sqlStmt, err)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func GetBlockTreesByPathPrefix(pathPrefix string) (ret []*BlockTree) {
|
||||
sqlStmt := "SELECT * FROM blocktrees WHERE path LIKE ?"
|
||||
rows, err := db.Query(sqlStmt, pathPrefix+"%")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue