Skip to content

Commit

Permalink
fix: add a subquery comment in *workflowArchive.ListWorkflows
Browse files Browse the repository at this point in the history
related to 9856df7

Signed-off-by: Xiaofan Hu <[email protected]>
  • Loading branch information
bom-d-van committed Sep 10, 2024
1 parent 7aa6dc7 commit 367f21c
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions persist/sqldb/workflow_archive.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,14 @@ func (r *workflowArchive) ListWorkflows(options sutils.ListOptions) (wfv1.Workfl
subSelector = r.session.SQL().Select(db.Raw("*")).From(subSelector).As("x")
}

// why using a subquery: the json unmarshaling process of coalesce
// (workflow) is always triggered for every records in the filtering query
// in postgres (and maybe mysql as well). by first filtering out uid first
// without trying to unmarshal the workflow, it kinda teach the database to
// delay the json parsing operation and thus speed up the query (could be
// up to 257 times faster for some deployments).
//
// more context: https://github.com/argoproj/argo-workflows/pull/13566
selector := r.session.SQL().Select(selectQuery).From(archiveTableName).Where(
r.clusterManagedNamespaceAndInstanceID().And(db.Cond{"uid IN": subSelector}),
)
Expand Down

0 comments on commit 367f21c

Please sign in to comment.