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 7, 2024
1 parent a3b3813 commit 31f1696
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_uuid, pod_uuid, MAX(last_update) as last_update
FROM container_log GROUP BY container_uuid) max_cl ON cl.container_uuid = max_cl.container_uuid AND cl.pod_uuid = max_cl.pod_uuid
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 31f1696

Please sign in to comment.