yii2: Super slow schema queries with MySQL 8.0.16
After updating to MySQL 8, I have noticed how super slow Yii2 has become. After using the Yii Debugger, I have found the following 6 queries consuming more than 95% of total loading time:
The only way I was able to fix the issue is by adding
'enableSchemaCache' => true,
to the database component and enabling caching class' => 'yii\caching\FileCache',
But since I’m using my machine for development I don’t want to enable caching.
Note: I tried the same code with MySQL version 5 and it was working fine. Seems an issue with MySQL 8 and Yii2, I’m not sure.
Additional info
Q | A |
---|---|
Yii version | 2.0.22 |
PHP version | 7.2.20 |
Operating system | macOS Mojave 10.14.5 |
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 44 (30 by maintainers)
Commits related to this issue
- Super slow schema queries with MySQL 8.0.16 fix #17444 — committed to kamarton/yiisoft-yii2 by kamarton 5 years ago
- changelog fix #17444 — committed to kamarton/yiisoft-yii2 by kamarton 5 years ago
- fix #17444 — committed to kamarton/yiisoft-yii2 by kamarton 5 years ago
- Fixing various schema drivers #17444 — committed to kamarton/yiisoft-yii2 by kamarton 5 years ago
- Fixing various schema drivers #17444 — committed to kamarton/yiisoft-yii2 by kamarton 5 years ago
- simple `$stop` #17444 — committed to kamarton/yiisoft-yii2 by kamarton 5 years ago
- refactoring and add more test+validate #17444 — committed to kamarton/yiisoft-yii2 by kamarton 5 years ago
- $resultIp move #17444 — committed to kamarton/yiisoft-yii2 by kamarton 5 years ago
- more test, fix code, refactoring, renaming #17444 — committed to kamarton/yiisoft-yii2 by kamarton 5 years ago
Same problem.
My DB has 43 tables.
I tried the following code as you suggested through a direct script and it took a lot of time 0.30296200
Doctrine’s affected by the same issue: https://github.com/doctrine/dbal/issues/4015
Could you show the result of this query?
Not sure if it could make a difference but MySQL 8 caches schema stats by default, not sure if that would happen with an upgrade.