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

sql/mysql: improve foreign-keys inspection query #1748

Merged
merged 1 commit into from
Jun 16, 2023
Merged

sql/mysql: improve foreign-keys inspection query #1748

merged 1 commit into from
Jun 16, 2023

Conversation

a8m
Copy link
Member

@a8m a8m commented Jun 16, 2023

EXPLAIN before is described here: #1727 (comment)

EXPLAIN after:

+----+-------------------+------------+------------+--------+------------------------+------------+---------+-----------------------+------+----------+----------------------------------------------+
| id | select_type       | table      | partitions | type   | possible_keys          | key        | key_len | ref                   | rows | filtered | Extra                                        |
+----+-------------------+------------+------------+--------+------------------------+------------+---------+-----------------------+------+----------+----------------------------------------------+
|  1 | PRIMARY           | cat        | NULL       | index  | PRIMARY                | name       | 194     | NULL                  |    1 |   100.00 | Using index; Using temporary; Using filesort |
|  1 | PRIMARY           | cat        | NULL       | index  | PRIMARY                | name       | 194     | NULL                  |    1 |   100.00 | Using index; Using join buffer (hash join)   |
|  1 | PRIMARY           | sch        | NULL       | ref    | PRIMARY,catalog_id     | catalog_id | 8       | mysql.cat.id          |    5 |   100.00 | Using where; Using index                     |
|  1 | PRIMARY           | tbl        | NULL       | ref    | schema_id              | schema_id  | 8       | mysql.sch.id          |   76 |   100.00 | Rematerialize (<derived3>)                   |
|  1 | PRIMARY           | <derived3> | NULL       | ALL    | NULL                   | NULL       | NULL    | NULL                  |    2 |   100.00 | NULL                                         |
|  1 | PRIMARY           | fk         | NULL       | ALL    | schema_id,table_id     | NULL       | NULL    | NULL                  |  840 |   100.00 | Using where; Using join buffer (hash join)   |
|  1 | PRIMARY           | sch        | NULL       | eq_ref | PRIMARY,catalog_id     | PRIMARY    | 8       | mysql.fk.schema_id    |    1 |   100.00 | Using where                                  |
|  1 | PRIMARY           | tbl        | NULL       | eq_ref | PRIMARY                | PRIMARY    | 8       | mysql.fk.table_id     |    1 |   100.00 | Using where                                  |
|  1 | PRIMARY           | col        | NULL       | eq_ref | PRIMARY                | PRIMARY    | 8       | constraints.column_id |    1 |   100.00 | Using where                                  |
|  3 | DEPENDENT DERIVED | NULL       | NULL       | NULL   | NULL                   | NULL       | NULL    | NULL                  | NULL |     NULL | Impossible WHERE                             |
|  4 | DEPENDENT UNION   | fk         | NULL       | ref    | PRIMARY,table_id       | table_id   | 8       | mysql.tbl.id          |    1 |   100.00 | NULL                                         |
|  4 | DEPENDENT UNION   | fkcu       | NULL       | ref    | PRIMARY,foreign_key_id | PRIMARY    | 8       | mysql.fk.id           |    1 |   100.00 | NULL                                         |
+----+-------------------+------------+------------+--------+------------------------+------------+---------+-----------------------+------+----------+----------------------------------------------+

Copy link
Member

@giautm giautm left a comment

Choose a reason for hiding this comment

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

💯

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants