Skip to content

Commit

Permalink
simplify in-line comment a bit
Browse files Browse the repository at this point in the history
Signed-off-by: Anton Gilgur <[email protected]>
  • Loading branch information
agilgur5 authored Sep 10, 2024
1 parent 91bf3a6 commit b715b42
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions persist/sqldb/workflow_archive.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,12 +184,9 @@ 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).
// why a subquery? the json unmarshal triggers for every row in the filter query.
// by filtering on uid first, we delay json parsing until a single row, speeding up the query
// (e.g. up to 257 times faster for some deployments).
selector := r.session.SQL().Select(selectQuery).From(archiveTableName).Where(
r.clusterManagedNamespaceAndInstanceID().And(db.Cond{"uid IN": subSelector}),
)
Expand Down

0 comments on commit b715b42

Please sign in to comment.