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

optimize UX for loading pipeline pages #1085

Merged
merged 6 commits into from
Apr 5, 2019
Merged

optimize UX for loading pipeline pages #1085

merged 6 commits into from
Apr 5, 2019

Conversation

IronPan
Copy link
Member

@IronPan IronPan commented Apr 5, 2019

speed up the query time for list runs

For example:
Before

SELECT subq.uuid, 
       "[" 
       || Group_concat(r.payload, ",") 
       || "]" AS refs 
FROM   (SELECT rd.*, 
               "[" 
               || Group_concat(m.payload, ",") 
               || "]" AS metrics 
        FROM   (SELECT * 
                FROM   run_details 
                WHERE  uuid IN (SELECT resourceuuid 
                                FROM   resource_references AS rf 
                                WHERE  ( rf.resourcetype = 'Run' 
                                         AND rf.referenceuuid = 'b7cc0970-e823-431a-a7d9-6b34407bbe17' 
                                         AND rf.referencetype = 'Experiment' ))) AS rd 
               LEFT JOIN run_metrics AS m 
                      ON rd.uuid = m.runuuid 
        GROUP  BY rd.uuid) AS subq 
       LEFT JOIN (SELECT * 
                  FROM   resource_references 
                  WHERE  resourcetype = 'Run') AS r 
              ON subq.uuid = r.resourceuuid 
GROUP  BY subq.uuid 
ORDER  BY createdatinsec ASC, 
          uuid ASC 
LIMIT  40;

After

SELECT subq.uuid, 
       "[" 
       || Group_concat(r.payload, ",") 
       || "]" AS refs 
FROM   (SELECT rd.*, 
               "[" 
               || Group_concat(m.payload, ",") 
               || "]" AS metrics 
        FROM   (SELECT * 
                FROM   run_details 
                WHERE  uuid IN (SELECT resourceuuid 
                                FROM   resource_references AS rf 
                                WHERE  ( rf.resourcetype = 'Run' 
                                         AND rf.referenceuuid = 'b7cc0970-e823-431a-a7d9-6b34407bbe17' 
                                         AND rf.referencetype = 'Experiment' )) ORDER  BY createdatinsec ASC, uuid ASC LIMIT  40) AS rd 
               LEFT JOIN run_metrics AS m 
                      ON rd.uuid = m.runuuid 
        GROUP  BY rd.uuid) AS subq 
       LEFT JOIN (SELECT * 
                  FROM   resource_references 
                  WHERE  resourcetype = 'Run') AS r 
              ON subq.uuid = r.resourceuuid 
GROUP  BY subq.uuid; 
ORDER  BY createdatinsec ASC, uuid ASC;

This change is Reviewable

@k8s-ci-robot k8s-ci-robot added size/M and removed size/S labels Apr 5, 2019
@IronPan
Copy link
Member Author

IronPan commented Apr 5, 2019

/assign @hongye-sun

@IronPan IronPan changed the title optimize query to paginate early paginate early to optimize query Apr 5, 2019
@IronPan
Copy link
Member Author

IronPan commented Apr 5, 2019

/hold
more optimization might be needed for further speedup

@k8s-ci-robot k8s-ci-robot added size/L and removed size/M labels Apr 5, 2019
@IronPan IronPan changed the title paginate early to optimize query optimize UX for loading pipeline pages Apr 5, 2019
@@ -150,7 +150,8 @@ message TerminateRunRequest {
}

message ListRunsResponse {
repeated Run runs = 1;
repeated Run runs = 1 [deprecated=true];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should hold off on this for now, but you change it if you think it's alright. The Run (not detail) part of the API is also used for the experiment list page, and I'm not sure yet that we'll always prefer the full run detail. it seems like the core part of this PR is still valuable without this.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reverted.

@IronPan
Copy link
Member Author

IronPan commented Apr 5, 2019

/hold cancel

Copy link
Contributor

@hongye-sun hongye-sun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@@ -145,21 +145,18 @@ func (s *RunStore) buildSelectRunsQuery(selectCount bool, opts *list.Options,
}

sqlBuilder := opts.AddFilterToSelect(filteredSelectBuilder)
if err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this removed?

sqlBuilder = s.addResourceReferences(sqlBuilder)
sqlBuilder = opts.AddPaginationToSelect(sqlBuilder)
sqlBuilder = opts.AddSortingToSelect(sqlBuilder)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just wonder if it's still required to add sorting query if inner result has already been sorted.

@IronPan
Copy link
Member Author

IronPan commented Apr 5, 2019

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: IronPan

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

1 similar comment
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: IronPan

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot merged commit ca3d100 into master Apr 5, 2019
@IronPan IronPan deleted the query branch May 30, 2019 07:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants