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

Conversation

wstian
Copy link
Contributor

@wstian wstian commented Nov 6, 2019

the current sql for runs list as below:

explain SELECT subq.*, CONCAT("[",GROUP_CONCAT(r.Payload SEPARATOR ","),"]") AS refs FROM (SELECT rd.*, CONCAT("[",GROUP_CONCAT(m.Payload SEPARATOR ","),"]") AS metrics FROM (SELECT UUID, DisplayName, Name, StorageState, Namespace, Description, CreatedAtInSec, ScheduledAtInSec, FinishedAtInSec, Conditions, PipelineId, PipelineName, PipelineSpecManifest, WorkflowSpecManifest, Parameters, pipelineRuntimeManifest, WorkflowRuntimeManifest FROM run_details WHERE UUID in (SELECT ResourceUUID FROM resource_references as rf WHERE (rf.ResourceType = 'Run' AND rf.ReferenceUUID = 'xxxx-177b4751-xxxx-xxxx-xxxx-xxxx' AND rf.ReferenceType = 'Experiment')) AND StorageState <> 'STORAGESTATE_ARCHIVED' ORDER BY CreatedAtInSec DESC, UUID DESC LIMIT 11) 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 DESC, UUID DESC;
+----+-------------+---------------------+--------+-------------------------+-----------------+---------+----------------------------+------+-----------------------------------------------------------+
| id | select_type | table               | type   | possible_keys           | key             | key_len | ref                        | rows | Extra                                                     |
+----+-------------+---------------------+--------+-------------------------+-----------------+---------+----------------------------+------+-----------------------------------------------------------+
|  1 | PRIMARY     | <derived2>          | ALL    | NULL                    | NULL            | NULL    | NULL                       |   11 | Using temporary; Using filesort                           |
|  1 | PRIMARY     | <derived5>          | ref    | <auto_key0>             | <auto_key0>     | 257     | subq.UUID                  |   30 | NULL                                                      |
|  5 | DERIVED     | resource_references | ref    | referencefilter         | referencefilter | 257     | const                      | 3047 | Using index condition                                     |
|  2 | DERIVED     | <derived3>          | ALL    | NULL                    | NULL            | NULL    | NULL                       |   11 | Using temporary; Using filesort                           |
|  2 | DERIVED     | m                   | ALL    | PRIMARY                 | NULL            | NULL    | NULL                       |    1 | Using where; Using join buffer (Block Nested Loop)        |
|  3 | DERIVED     | rf                  | ref    | PRIMARY,referencefilter | referencefilter | 771     | const,const,const          |  302 | Using where; Using index; Using temporary; Using filesort |
|  3 | DERIVED     | run_details         | eq_ref | PRIMARY                 | PRIMARY         | 257     | mlpipeline.rf.ResourceUUID |    1 | Using where                                               |
+----+-------------+---------------------+--------+-------------------------+-----------------+---------+----------------------------+------+-----------------------------------------------------------+

the union index as below:

mysql> show index from resource_references;
+---------------------+------------+-----------------+--------------+---------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| Table               | Non_unique | Key_name        | Seq_in_index | Column_name   | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment |
+---------------------+------------+-----------------+--------------+---------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| resource_references |          0 | PRIMARY         |            1 | ResourceUUID  | A         |        6095 |     NULL | NULL   |      | BTREE      |         |               |
| resource_references |          0 | PRIMARY         |            2 | ResourceType  | A         |        6095 |     NULL | NULL   |      | BTREE      |         |               |
| resource_references |          0 | PRIMARY         |            3 | ReferenceType | A         |        6095 |     NULL | NULL   |      | BTREE      |         |               |
| resource_references |          1 | referencefilter |            1 | ResourceType  | A         |           4 |     NULL | NULL   |      | BTREE      |         |               |
| resource_references |          1 | referencefilter |            2 | ReferenceUUID | A         |          64 |     NULL | NULL   |      | BTREE      |         |               |
| resource_references |          1 | referencefilter |            3 | ReferenceType | A         |          64 |     NULL | NULL   |      | BTREE      |         |               |
+---------------------+------------+-----------------+--------------+---------------+-----------+-------------+----------+--------+------+------------+---------+---------------+

the left join query as below, the union index doesn't work

subq LEFT JOIN (select * from resource_references where ResourceType='Run') AS r ON subq.UUID=r.ResourceUUID

change the left join as below:

subq LEFT JOIN resource_references AS r ON r.ResourceType='Run' AND subq.UUID=r.ResourceUUID

the result as below:

mysql> explain SELECT subq.*, CONCAT("[",GROUP_CONCAT(r.Payload SEPARATOR ","),"]") AS refs FROM (SELECT rd.*, CONCAT("[",GROUP_CONCAT(m.Payload SEPARATOR ","),"]") AS metrics FROM (SELECT UUID, DisplayName, Name, StorageState, Namespace, Description, CreatedAtInSec, ScheduledAtInSec, FinishedAtInSec, Conditions, PipelineId, PipelineName, PipelineSpecManifest, WorkflowSpecManifest, Parameters, pipelineRuntimeManifest, WorkflowRuntimeManifest FROM run_details WHERE UUID in (SELECT ResourceUUID FROM resource_references as rf WHERE (rf.ResourceType = 'Run' AND rf.ReferenceUUID = 'xxxx-177b4751-xxxx-xxxx' AND rf.ReferenceType = 'Experiment')) AND StorageState <> 'STORAGESTATE_ARCHIVED' ORDER BY CreatedAtInSec DESC, UUID DESC LIMIT 11) AS rd LEFT JOIN run_metrics AS m ON rd.UUID=m.RunUUID GROUP BY rd.UUID) AS subq LEFT JOIN resource_references AS r ON r.ResourceType='Run' AND subq.UUID=r.ResourceUUID GROUP BY subq.UUID ORDER BY CreatedAtInSec DESC, UUI
+----+-------------+-------------+--------+-------------------------+-----------------+---------+----------------------------+------+-----------------------------------------------------------+
| id | select_type | table       | type   | possible_keys           | key             | key_len | ref                        | rows | Extra                                                     |
+----+-------------+-------------+--------+-------------------------+-----------------+---------+----------------------------+------+-----------------------------------------------------------+
|  1 | PRIMARY     | <derived2>  | ALL    | NULL                    | NULL            | NULL    | NULL                       |   11 | Using temporary; Using filesort                           |
|  1 | PRIMARY     | r           | ref    | PRIMARY,referencefilter | PRIMARY         | 514     | subq.UUID,const            |    1 | Using where                                               |
|  2 | DERIVED     | <derived3>  | ALL    | NULL                    | NULL            | NULL    | NULL                       |   11 | Using temporary; Using filesort                           |
|  2 | DERIVED     | m           | ALL    | PRIMARY                 | NULL            | NULL    | NULL                       |    1 | Using where; Using join buffer (Block Nested Loop)        |
|  3 | DERIVED     | rf          | ref    | PRIMARY,referencefilter | referencefilter | 771     | const,const,const          |  302 | Using where; Using index; Using temporary; Using filesort |
|  3 | DERIVED     | run_details | eq_ref | PRIMARY                 | PRIMARY         | 257     | mlpipeline.rf.ResourceUUID |    1 | Using where                                               |
+----+-------------+-------------+--------+-------------------------+-----------------+---------+----------------------------+------+-----------------------------------------------------------+

This change is Reviewable

@googlebot
Copy link
Collaborator

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here with @googlebot I signed it! and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

ℹ️ Googlers: Go here for more info.

@k8s-ci-robot
Copy link
Contributor

Hi @wstian. Thanks for your PR.

I'm waiting for a kubeflow member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@wstian
Copy link
Contributor Author

wstian commented Nov 6, 2019

@googlebot I signed it!

@wstian
Copy link
Contributor Author

wstian commented Nov 6, 2019

this commit fixes #2071

@numerology
Copy link

/ok-to-test

@numerology
Copy link

/assign @jingzhang36
/assign @IronPan

@IronPan
Copy link
Member

IronPan commented Nov 7, 2019

Thanks @wstian!
/lgtm
/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

@IronPan
Copy link
Member

IronPan commented Nov 7, 2019

@wstian could you double check the CLA? Thanks!

@wstian
Copy link
Contributor Author

wstian commented Nov 8, 2019

@googlebot I signed it!

@wstian
Copy link
Contributor Author

wstian commented Nov 8, 2019

@googlebot I signed it!

i think it should be OK now. I have signed the CLA with the commit email

@googlebot
Copy link
Collaborator

CLAs look good, thanks!

ℹ️ Googlers: Go here for more info.

@Bobgy
Copy link
Contributor

Bobgy commented Nov 11, 2019

This PR seems to be stuck in prow bot's merge pool. Although it shouldn't get merged yet. One test is failing.

@Bobgy Bobgy removed the lgtm label Nov 11, 2019
@Bobgy
Copy link
Contributor

Bobgy commented Nov 11, 2019

/lgtm

@rmgogogo
Copy link
Contributor

/test

@rmgogogo
Copy link
Contributor

/lgtm

@wstian
Copy link
Contributor Author

wstian commented Nov 12, 2019

/test kubeflow-pipeline-e2e-test

@k8s-ci-robot k8s-ci-robot merged commit d775470 into kubeflow:master Nov 12, 2019
magdalenakuhn17 pushed a commit to magdalenakuhn17/pipelines that referenced this pull request Oct 22, 2023
* Adding doc for release process v2

Signed-off-by: rachitchauhan43 <rachitchauhan43@gmail.com>

* Adding doc for release process v2

Signed-off-by: rachitchauhan43 <rachitchauhan43@gmail.com>

* Updating for new cadence

Signed-off-by: rachitchauhan43 <rachitchauhan43@gmail.com>

* Updating for new cadence

Signed-off-by: rachitchauhan43 <rachitchauhan43@gmail.com>

* Added instructions for release day
Signed-off-by: rachitchauhan43 <rachitchauhan43@gmail.com>

Signed-off-by: rachitchauhan43 <rachitchauhan43@gmail.com>

* Updating release docs

Signed-off-by: rachitchauhan43 <rachitchauhan43@gmail.com>

* Updating release docs

Signed-off-by: rachitchauhan43 <rachitchauhan43@gmail.com>

* Updating release docs

Signed-off-by: rachitchauhan43 <rachitchauhan43@gmail.com>

---------

Signed-off-by: rachitchauhan43 <rachitchauhan43@gmail.com>
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.

8 participants