laracraft-tech / laravel-xhprof

Easy XHProf setup to profile your Laravel application!
MIT License
219 stars 11 forks source link

[1.x] id column has not index! #15

Closed ktanakaj closed 10 months ago

ktanakaj commented 11 months ago

Version

v1.0.9

Database Driver

MySQL

Description

I created details table using the following command: php artisan vendor:publish --provider="LaracraftTech\LaravelXhprof\XHProfServiceProvider" --tag="migrations"

I was able to view the xhprof page the first time, but after a while, the xhprof page timed out. I found the following slow query in the MySQL slow query log:

`SELECT * FROM `details` WHERE `id` = '651e3280bba53';`

OMG, I discovered that the id column in the details table does not have an index!

The id column requires an index, perhaps even a unique key instead of just an index.

Sairahcaz commented 11 months ago

@ktanakaj thanks for your report. I just took the SQL statement from the XHGUI and did not have a closer look. I think I'll gonna fix this. Also the idcount field seems not to be used. So maybe it can be dropped... May I ask, how many entries do you have in your detailstable?

ktanakaj commented 11 months ago

Thanks for the quick response. My details table has over one hundred thousand records.

MySQL [mydb]> SELECT COUNT(*) FROM details;
+----------+
| COUNT(*) |
+----------+
|   117220 |
+----------+
Sairahcaz commented 10 months ago

@ktanakaj it's fixed: https://github.com/laracraft-tech/laravel-xhprof/releases/tag/v1.0.10

Feel free to update the package and republish/remigrate the new migration!