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

MySQL loadTables performance #6800

Closed
ronits-cx opened this issue Sep 29, 2020 · 0 comments · Fixed by #6886
Closed

MySQL loadTables performance #6800

ronits-cx opened this issue Sep 29, 2020 · 0 comments · Fixed by #6886

Comments

@ronits-cx
Copy link
Contributor

ronits-cx commented Sep 29, 2020

Issue type:

[x] bug report
[ ] feature request
[ ] documentation issue

Database system/driver:

[ ] cordova
[ ] mongodb
[ ] mssql
[x] mysql / mariadb
[ ] oracle
[ ] postgres
[ ] cockroachdb
[ ] sqlite
[ ] sqljs
[ ] react-native
[ ] expo

TypeORM version:

[ ] latest
[ ] @next
[ ] 0.x.x (or put your version here)

Steps to reproduce or a small repository showing the problem:

In `MysqlQueryRunner`, `loadTables` performs queries to `INFORMATION_SCHEMA`, which is not optimized.
MySQL recommends adding a where clause with the schema and table for better performance - https://dev.mysql.com/doc/refman/5.7/en/information-schema-optimization.html.

There are 2 queries with a JOIN that have a where clause on the schema and table, but the where clause is only for one of the tables in the join.
In the foreign key query, this causes an actual bug (which is what https://github.com//pull/6169/files solves).

For large databases with many schemas, this can be a crucial improvement.
In our database, for example, each of these queries takes about **7.5 seconds**.
If a where clause is added to the second table in the join, the query takes around **200 milliseconds**.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants