Comments (8)
Yes, a separate tab would indeed be good. Then it can even be grouped by the stack trace.
from yii2-debug.
How many actual queries are there?
from yii2-debug.
How many actual queries are there?
In total there were 70 queries in the example. The excessive 20 queries were in this case caused because the related models were not eager loaded. So in this case the total number of queries for the request could be reduced to 51 (70 - 20 duplicates + 1 for the eager loading).
from yii2-debug.
What is the actual benefit of this?
from yii2-debug.
@bizley
The main goal is to detect programming mistakes like not eager loading data. For example a REST API index action returns 20 models. When serializing those models a lot of additional queries might automatically be executed to populate relational data when there is no eager loading of those relations.
The current 'duplicates' functionality is not able to detect those repeated calls since the query itself is different each time (in the screenshot above the id
value in SELECT * FROM users WHERE id=x.
).
Similar to the current $criticalQueryThreshold
we can add a $repeatingCallerCallsCriticalThreshold
(with a much lower value) providing a warning if the same code makes a lot of DB queries.
from yii2-debug.
So the actual number of queries per line is not 1 but 20? If so then it could be considered a bug that it displays 1.
from yii2-debug.
No, there is only one query per row, similar to the current 'duplicates'.
If there are two duplicate queries, you would see 2 rows, each showing 2
duplicates.
For reference, the existing 'duplicates' implementation: #281 (comment)
Duplicates occur when the exact same query is executed (could be the same or different source code). E.g:
File:Line | Query | DB Panel 'Duplicates' | DB Panel 'Repeating calls' |
---|---|---|---|
User.php:20 | SELECT * FROM user WHERE id=123; |
2 | 0 |
Test.php:55 | SELECT * FROM user WHERE id=123; |
2 | 0 |
Results in 2 duplicates, 0 repeating callers.
Repeating calls occur when the exact same source code makes a DB call (could be the same or different queries). E.g:
File:Line | Query | DB Panel 'Duplicates' | DB Panel 'Repeating calls' |
---|---|---|---|
User.php:75 | SELECT * FROM user WHERE id=123; |
0 | 3 |
User.php:75 | SELECT * FROM user WHERE id=456; |
0 | 3 |
User.php:75 | SELECT * FROM user WHERE id=789; |
0 | 3 |
Results in 0 duplicates, 1 repeating caller making 3 repeating calls.
A combination of both duplicates and repeating calls is also possible E.g:
File:Line | Query | DB Panel 'Duplicates' | DB Panel 'Repeating calls' |
---|---|---|---|
User.php:75 | SELECT * FROM user WHERE id=123; |
2 | 3 |
User.php:75 | SELECT * FROM user WHERE id=456; |
0 | 3 |
User.php:75 | SELECT * FROM user WHERE id=789; |
0 | 3 |
Test.php:55 | SELECT * FROM user WHERE id=123; |
2 | 0 |
Results in 2 duplicates, 1 repeating caller making 3 repeating calls.
from yii2-debug.
Ah, now I get it. While it's useful, I think it likely should be a separate panel since this number is not per query.
from yii2-debug.
Related Issues (20)
- Please rewrite comments HOT 4
- Store data in a cache HOT 3
- User switching is not working when using custom User model id HOT 1
- Mailpanel should store message in request data HOT 1
- User switch not working if User model has JSON/Array column HOT 2
- Don't use table-danger to indicate excessive queries HOT 3
- DB summary view uses $criticalQueryThreshold directly instead of checking via isQueryCountCritical() method HOT 2
- Mail panel broken for Symfonimailer HOT 1
- List of queries in debug panel is empty when Connection::enableProfiling is false
- Display transaction begin/end in debug panel database queries list
- DbPanel::excessiveCallerThreshold should be disabled by default
- Object of class Symfony\Component\Mime\Header\Headers could not be converted to string HOT 2
- update irc link
- update github folder link
- update docs folder links
- Switching user back to admin user is not possible when using access rules
- update src folder links
- update root folder links
- Generating a url with a trailing slash
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from yii2-debug.