search v2: pre-allocate dashboardQueryResult slice capacity for performance (#91536)

* search v2: pre-allocate dashboardQueryResult slice for performance
* use limit parameter for starting slice size
This commit is contained in:
Kristin Laemmert 2024-08-05 13:54:57 -04:00 committed by GitHub
parent 53cfdf0ef8
commit b6de9e9d3c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -846,7 +846,7 @@ func (l sqlDashboardLoader) loadAllDashboards(ctx context.Context, limit int, or
attribute.Int64("lastID", lastID),
))
rows := make([]*dashboardQueryResult, 0)
rows := make([]*dashboardQueryResult, 0, limit)
err := l.sql.WithDbSession(dashboardQueryCtx, func(sess *db.Session) error {
sess.Table("dashboard").
Where("org_id = ?", orgID).