Add indexes to improve performance
This commit is contained in:
parent
6086899b28
commit
5dc44453ba
2 changed files with 18 additions and 2 deletions
|
@ -783,4 +783,20 @@ var migrations = []func(tx *sql.Tx) error{
|
|||
_, err = tx.Exec(sql)
|
||||
return err
|
||||
},
|
||||
func(tx *sql.Tx) (err error) {
|
||||
sql := `
|
||||
-- Speed up has_enclosure
|
||||
CREATE INDEX enclosures_entry_id_idx ON enclosures(entry_id);
|
||||
|
||||
-- Speed up unread page
|
||||
CREATE INDEX entries_user_status_published_idx ON entries(user_id, status, published_at);
|
||||
CREATE INDEX entries_user_status_created_idx ON entries(user_id, status, created_at);
|
||||
CREATE INDEX feeds_feed_id_hide_globally_idx ON feeds(id, hide_globally);
|
||||
|
||||
-- Speed up history page
|
||||
CREATE INDEX entries_user_status_changed_published_idx ON entries(user_id, status, changed_at, published_at);
|
||||
`
|
||||
_, err = tx.Exec(sql)
|
||||
return err
|
||||
},
|
||||
}
|
||||
|
|
|
@ -212,8 +212,8 @@ func (e *EntryQueryBuilder) WithOffset(offset int) *EntryQueryBuilder {
|
|||
}
|
||||
|
||||
func (e *EntryQueryBuilder) WithGloballyVisible() *EntryQueryBuilder {
|
||||
e.conditions = append(e.conditions, "not c.hide_globally")
|
||||
e.conditions = append(e.conditions, "not f.hide_globally")
|
||||
e.conditions = append(e.conditions, "c.hide_globally IS FALSE")
|
||||
e.conditions = append(e.conditions, "f.hide_globally IS FALSE")
|
||||
return e
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue