[DBAL-11] Improve API of Sqllogger Created: 06/Nov/09 Updated: 20/Jun/10 Resolved: 20/Jun/10
|Reporter:||Benjamin Eberlei||Assignee:||Benjamin Eberlei|
The SqlLogger currently has a very simple API, which lacks for example the possibilty to log the execution time of queries. This would require a second call of the logger however, but i made some performance tests on the current implementation. Its using the following check to look if logging is enabled:
Only takes half the time. See the test at the bottom.
We could switch to a boolean flag and use the "saved" time to enhance the SQL Logger API to include the following information:
1. SQL (Have already)
This would benefit both Symfony and ZF since they could hook into the logger for their respective debugging facilities (sf Web Toolbar, Zend Firebug SQL Profiling).
|Comment by Roman S. Borschel [ 07/Nov/09 ]|
Yea, its currently a known limitation that the times do not get logged. However, I have real doubts as to whether that is actually useful as such measurements from PHP are very inaccurate. Its much better to copy+paste a SQL query to a SQL console and run it with ANALYZE/EXPLAIN ... to see its performance.
sfDoctrine2Plugin already uses this logger for its debug toolbar.
|Comment by David Abdemoulaie [ 10/Apr/10 ]|
Such timings are very useful. The accuracy isn't really the point. If you have N queries executing on a slow request, you have to check N queries to find the problem. With a simple "inaccurate" time measurement you'd be able to quickly identify the problem query(ies) and take further action.
|Comment by Roman S. Borschel [ 14/May/10 ]|
I think timings can be added.
|Comment by Benjamin Eberlei [ 13/Jun/10 ]|
Schedule for BETA 3
|Comment by Benjamin Eberlei [ 20/Jun/10 ]|
Implemented this change, the interface of the SQL Logger changed to:
Additionally the contract of loggers changed, they are now invoked AFTER a query is executed therefore queries that cause failures do not appear on the logs.