Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix slow query when get runs #2559

Merged
merged 2 commits into from
Nov 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 16 additions & 16 deletions backend/src/apiserver/resource/resource_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1179,14 +1179,6 @@ func TestReportWorkflowResource_ScheduledWorkflowIDNotEmpty_Success(t *testing.T
WorkflowSpecManifest: workflow.GetWorkflowSpec().ToStringForStore(),
},
ResourceReferences: []*model.ResourceReference{
{
ResourceUUID: "WORKFLOW_1",
ResourceType: common.Run,
ReferenceUUID: job.UUID,
ReferenceName: job.Name,
ReferenceType: common.Job,
Relationship: common.Creator,
},
{
ResourceUUID: "WORKFLOW_1",
ResourceType: common.Run,
Expand All @@ -1195,6 +1187,14 @@ func TestReportWorkflowResource_ScheduledWorkflowIDNotEmpty_Success(t *testing.T
ReferenceType: common.Experiment,
Relationship: common.Owner,
},
{
ResourceUUID: "WORKFLOW_1",
ResourceType: common.Run,
ReferenceUUID: job.UUID,
ReferenceName: job.Name,
ReferenceType: common.Job,
Relationship: common.Creator,
},
},
},
PipelineRuntime: model.PipelineRuntime{WorkflowRuntimeManifest: workflow.ToStringForStore()},
Expand Down Expand Up @@ -1252,14 +1252,6 @@ func TestReportWorkflowResource_ScheduledWorkflowIDNotEmpty_NoExperiment_Success
WorkflowSpecManifest: workflow.GetWorkflowSpec().ToStringForStore(),
},
ResourceReferences: []*model.ResourceReference{
{
ResourceUUID: "WORKFLOW_1",
ResourceType: common.Run,
ReferenceUUID: newJob.UUID,
ReferenceName: newJob.Name,
ReferenceType: common.Job,
Relationship: common.Creator,
},
{
ResourceUUID: "WORKFLOW_1",
ResourceType: common.Run,
Expand All @@ -1268,6 +1260,14 @@ func TestReportWorkflowResource_ScheduledWorkflowIDNotEmpty_NoExperiment_Success
ReferenceType: common.Experiment,
Relationship: common.Owner,
},
{
ResourceUUID: "WORKFLOW_1",
ResourceType: common.Run,
ReferenceUUID: newJob.UUID,
ReferenceName: newJob.Name,
ReferenceType: common.Job,
Relationship: common.Creator,
},
},
},
PipelineRuntime: model.PipelineRuntime{WorkflowRuntimeManifest: workflow.ToStringForStore()},
Expand Down
2 changes: 1 addition & 1 deletion backend/src/apiserver/storage/run_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ func (s *RunStore) addMetricsAndResourceReferences(filteredSelectBuilder sq.Sele
Select("subq.*", resourceRefConcatQuery+" AS refs").
FromSelect(subQ, "subq").
// Append all the resource references for the run as a json column
LeftJoin("(select * from resource_references where ResourceType='Run') AS r ON subq.UUID=r.ResourceUUID").
LeftJoin("resource_references AS r ON r.ResourceType='Run' AND subq.UUID=r.ResourceUUID").
GroupBy("subq.UUID")
}

Expand Down