mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-12-05 00:38:07 -06:00
[chore/performance] Avoid unnecessary "uncached" queries (#3265)
* [chore/performance] Avoid unnecessary "uncached" queries * go fmt
This commit is contained in:
parent
f924297af1
commit
25a815a8a4
17 changed files with 149 additions and 21 deletions
|
|
@ -54,8 +54,15 @@ func (s *statusDB) GetStatusesByIDs(ctx context.Context, ids []string) ([]*gtsmo
|
|||
statuses, err := s.state.Caches.DB.Status.LoadIDs("ID",
|
||||
ids,
|
||||
func(uncached []string) ([]*gtsmodel.Status, error) {
|
||||
// Avoid querying
|
||||
// if none uncached.
|
||||
count := len(uncached)
|
||||
if count == 0 {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
// Preallocate expected length of uncached statuses.
|
||||
statuses := make([]*gtsmodel.Status, 0, len(uncached))
|
||||
statuses := make([]*gtsmodel.Status, 0, count)
|
||||
|
||||
// Perform database query scanning
|
||||
// the remaining (uncached) status IDs.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue