mirror of
https://github.com/grafana/grafana.git
synced 2025-01-16 11:42:35 -06:00
Storage: optimize sql list operation (#53009)
This commit is contained in:
parent
08dabfaffc
commit
046a2602ff
@ -33,6 +33,11 @@ type file struct {
|
||||
MimeType string `xorm:"mime_type"`
|
||||
}
|
||||
|
||||
var (
|
||||
fileColsNoContents = []string{"path", "path_hash", "parent_folder_path_hash", "etag", "cache_control", "content_disposition", "updated", "created", "size", "mime_type"}
|
||||
allFileCols = append([]string{"contents"}, fileColsNoContents...)
|
||||
)
|
||||
|
||||
type fileMeta struct {
|
||||
PathHash string `xorm:"path_hash"`
|
||||
Key string `xorm:"key"`
|
||||
@ -339,6 +344,12 @@ func (s dbFileStorage) List(ctx context.Context, folderPath string, paging *Pagi
|
||||
sess.Where("path > ?", cursor)
|
||||
}
|
||||
|
||||
if options.WithContents {
|
||||
sess.Cols(allFileCols...)
|
||||
} else {
|
||||
sess.Cols(fileColsNoContents...)
|
||||
}
|
||||
|
||||
if err := sess.Find(&foundFiles); err != nil {
|
||||
return err
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user