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

improve the list run query #687

Merged
merged 2 commits into from
Jan 15, 2019
Merged

improve the list run query #687

merged 2 commits into from
Jan 15, 2019

Conversation

IronPan
Copy link
Member

@IronPan IronPan commented Jan 15, 2019

Move the filter on resource reference to the first select statement in the nested sql

SELECT subq.*, 
       "[" 
       || 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 = ? 
                                         AND rf.referenceuuid = ? 
                                         AND rf.referencetype = ? ))) 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 
WHERE  ( createdatinsec > ? 
          OR ( createdatinsec = ? 
               AND uuid >= ? ) ) 
GROUP  BY subq.uuid 
ORDER  BY createdatinsec ASC, 
          uuid ASC 
LIMIT  2 

This change is Reviewable

@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

@IronPan IronPan changed the title optimize list run query improve the list run query Jan 15, 2019
@IronPan
Copy link
Member Author

IronPan commented Jan 15, 2019

/assign @yebrahim

Copy link
Contributor

@yebrahim yebrahim left a comment

Choose a reason for hiding this comment

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

LGTM. Does it make sense to have unit tests that validate the final raw queries built by using these blocks? It's easy when refactoring this code to result in less efficient queries that will still pass correctness unit tests.

/lgtm

return selectBuilder, util.NewInternalServerError(err, "Failed to append filter condition to list job: %v",
err.Error())
}
func (s *JobStore) toFilteredQuery(filterContext *common.FilterContext) (sq.SelectBuilder, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: since this doesn't take a query anymore, maybe rename to buildFilteredQuery or something similar?

@k8s-ci-robot k8s-ci-robot merged commit c2834c3 into kubeflow:master Jan 15, 2019
Linchin pushed a commit to Linchin/pipelines that referenced this pull request Apr 11, 2023
Minor typo error in the example yaml as I understand.
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.

3 participants