Skip to content

Commit

Permalink
Update warmup function to optimize container log retrieval
Browse files Browse the repository at this point in the history
  • Loading branch information
jhoxhaa committed Jun 3, 2024
1 parent f6f5d9a commit 7ffff1e
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pkg/schema/v1/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -289,9 +289,13 @@ func SyncContainers(ctx context.Context, db *database.Database, g *errgroup.Grou
func warmup(ctx context.Context, db *database.Database) error {
g, ctx := errgroup.WithContext(ctx)

query := `SELECT cl.* FROM container_log cl INNER JOIN (SELECT container_id, pod_id, MAX(last_update) as last_update
FROM container_log GROUP BY container_id) max_cl ON cl.container_id = max_cl.container_id AND cl.pod_id = max_cl.pod_id
AND cl.last_update = max_cl.last_update`

entities, errs := db.YieldAll(ctx, func() (interface{}, error) {
return &ContainerLog{}, nil
}, db.BuildSelectStmt(ContainerLog{}, ContainerLog{}))
}, query)
com.ErrgroupReceive(ctx, g, errs)

g.Go(func() error {
Expand Down

0 comments on commit 7ffff1e

Please sign in to comment.