mirror of https://github.com/jlelse/GoBlog
Improve performance for media search
This commit is contained in:
parent
6f4d4a646d
commit
d98ae73af0
|
@ -472,8 +472,8 @@ func (d *database) allPublishedDates(blog string) (dates []publishedDate, err er
|
|||
}
|
||||
|
||||
func (db *database) usesOfMediaFile(name string) (count int, err error) {
|
||||
query := "select count(distinct path) from (select path from posts where instr(content, @name) > 0 union all select path from post_parameters where instr(value, @name) > 0)"
|
||||
row, err := db.queryRow(query, sql.Named("name", name))
|
||||
query := "select count(distinct path) from (select path from posts_fts where content match @fts_name union all select path from post_parameters where instr(value, @name) > 0)"
|
||||
row, err := db.queryRow(query, sql.Named("fts_name", fmt.Sprintf("\"%s\"", name)), sql.Named("name", name))
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue