<!-- 
RSS generated by JIRA (5.2.7#850-sha1:b2af0c8dc8537b36121c6a579fabbdf79fc919e5) at Mon May 20 05:54:36 UTC 2013

It is possible to restrict the fields that are returned in this document by specifying the 'field' parameter in your request.
For example, to request only the issue key and summary add field=key&field=summary to the URL of your request.
For example:
http://www.doctrine-project.org/jira/si/jira.issueviews:issue-xml/DBAL-11/DBAL-11.xml?field=key&field=summary
-->
<rss version="0.92" >
<channel>
    <title>Doctrine Project</title>
    <link>http://www.doctrine-project.org/jira</link>
    <description>This file is an XML representation of an issue</description>
    <language>en-us</language>    <build-info>
        <version>5.2.7</version>
        <build-number>850</build-number>
        <build-date>21-02-2013</build-date>
    </build-info>

<item>
            <title>[DBAL-11] Improve API of Sqllogger</title>
                <link>http://www.doctrine-project.org/jira/browse/DBAL-11</link>
                <project id="10040" key="DBAL">Doctrine DBAL</project>
                        <description>&lt;p&gt;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:&lt;/p&gt;

&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-java&quot;&gt;&lt;span class=&quot;code-keyword&quot;&gt;if&lt;/span&gt;($&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;_config-&amp;gt;getSqlLogger())
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;However:&lt;/p&gt;

&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-java&quot;&gt;&lt;span class=&quot;code-keyword&quot;&gt;if&lt;/span&gt;($&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;_hasLogger)
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Only takes half the time.  See the test at the bottom.&lt;/p&gt;

&lt;p&gt;We could switch to a boolean flag and use the &quot;saved&quot; time to enhance the SQL Logger API to include the following information:&lt;/p&gt;

&lt;p&gt;1. SQL (Have already)&lt;br/&gt;
2. Params (Have already)&lt;br/&gt;
3. Elapsed Time (Start Time and End Time)&lt;br/&gt;
4. Query Type (SELECT, INSERT, UPDATE, DELETE, OTHER)&lt;/p&gt;

&lt;p&gt;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).&lt;/p&gt;

&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-java&quot;&gt;&amp;lt;?php                                                                                             
class Config                                                                                      
{                                                                                                 
    &lt;span class=&quot;code-keyword&quot;&gt;protected&lt;/span&gt; $_logger;                                                                           
    &lt;span class=&quot;code-keyword&quot;&gt;public&lt;/span&gt; function __construct()                                                                 
    {                                                                                             
        $&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;_logger = &lt;span class=&quot;code-keyword&quot;&gt;new&lt;/span&gt; stdClass();
    }
    &lt;span class=&quot;code-keyword&quot;&gt;public&lt;/span&gt; function getLogger()
    {
        &lt;span class=&quot;code-keyword&quot;&gt;return&lt;/span&gt; $&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;_logger;
    }
}

class Foo
{
    &lt;span class=&quot;code-keyword&quot;&gt;protected&lt;/span&gt; $_config = &lt;span class=&quot;code-keyword&quot;&gt;null&lt;/span&gt;;
    &lt;span class=&quot;code-keyword&quot;&gt;public&lt;/span&gt; function __construct()
    {
         $&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;_config = &lt;span class=&quot;code-keyword&quot;&gt;new&lt;/span&gt; Config();
    }
    &lt;span class=&quot;code-keyword&quot;&gt;public&lt;/span&gt; function execute()
    {
         &lt;span class=&quot;code-keyword&quot;&gt;if&lt;/span&gt;($&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;_config-&amp;gt;getLogger()) {
         }
    }
}

class Bar
{
    &lt;span class=&quot;code-keyword&quot;&gt;protected&lt;/span&gt; $_config = &lt;span class=&quot;code-keyword&quot;&gt;null&lt;/span&gt;;
    &lt;span class=&quot;code-keyword&quot;&gt;protected&lt;/span&gt; $_loggerExists = &lt;span class=&quot;code-keyword&quot;&gt;false&lt;/span&gt;;
    &lt;span class=&quot;code-keyword&quot;&gt;public&lt;/span&gt; function __construct()
    {
         $&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;_config = &lt;span class=&quot;code-keyword&quot;&gt;new&lt;/span&gt; stdClass();
         $&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;_loggerExists = &lt;span class=&quot;code-keyword&quot;&gt;true&lt;/span&gt;;
    }
    &lt;span class=&quot;code-keyword&quot;&gt;public&lt;/span&gt; function execute()
    {
        &lt;span class=&quot;code-keyword&quot;&gt;if&lt;/span&gt;($&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;_loggerExists) {

        }
    }
}

$f = &lt;span class=&quot;code-keyword&quot;&gt;new&lt;/span&gt; Foo();
$s = microtime(&lt;span class=&quot;code-keyword&quot;&gt;true&lt;/span&gt;);
&lt;span class=&quot;code-keyword&quot;&gt;for&lt;/span&gt;($i = 0; $i &amp;lt; 100; $i++) {
    $f-&amp;gt;execute();
}
echo (microtime(&lt;span class=&quot;code-keyword&quot;&gt;true&lt;/span&gt;)-$s).&lt;span class=&quot;code-quote&quot;&gt;&quot;s\n&quot;&lt;/span&gt;;

$f = &lt;span class=&quot;code-keyword&quot;&gt;new&lt;/span&gt; Bar();
$s = microtime(&lt;span class=&quot;code-keyword&quot;&gt;true&lt;/span&gt;);
&lt;span class=&quot;code-keyword&quot;&gt;for&lt;/span&gt;($i = 0; $i &amp;lt; 100; $i++) {
    $f-&amp;gt;execute();
}
echo (microtime(&lt;span class=&quot;code-keyword&quot;&gt;true&lt;/span&gt;)-$s).&lt;span class=&quot;code-quote&quot;&gt;&quot;s\n&quot;&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-java&quot;&gt;benny@benny-pc:~/code/php/wsnetbeans/Doctrine/trunk/tests$ php /tmp/boolvsmethod.php                
0.00055313110351562s                                                                                  
0.00025200843811035s                                                                                  
benny@benny-pc:~/code/php/wsnetbeans/Doctrine/trunk/tests$ php /tmp/boolvsmethod.php                
0.00051999092102051s                                                                                
0.00025200843811035s                                                                                
benny@benny-pc:~/code/php/wsnetbeans/Doctrine/trunk/tests$ php /tmp/boolvsmethod.php                
0.00036001205444336s                                                                                
0.00017309188842773s                                                                                
benny@benny-pc:~/code/php/wsnetbeans/Doctrine/trunk/tests$ php /tmp/boolvsmethod.php                
0.0005180835723877s                                                                                 
0.00025010108947754s 
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;</description>
                <environment></environment>
            <key id="10358">DBAL-11</key>
            <summary>Improve API of Sqllogger</summary>
                <type id="4" iconUrl="http://www.doctrine-project.org/jira/images/icons/issuetypes/improvement.png">Improvement</type>
                                <priority id="4" iconUrl="http://www.doctrine-project.org/jira/images/icons/priorities/minor.png">Minor</priority>
                    <status id="5" iconUrl="http://www.doctrine-project.org/jira/images/icons/statuses/resolved.png">Resolved</status>
                    <resolution id="1">Fixed</resolution>
                                <assignee username="beberlei">Benjamin Eberlei</assignee>
                                <reporter username="beberlei">Benjamin Eberlei</reporter>
                        <labels>
                    </labels>
                <created>Fri, 6 Nov 2009 18:04:02 +0000</created>
                <updated>Sun, 20 Jun 2010 10:52:27 +0000</updated>
                    <resolved>Sun, 20 Jun 2010 10:52:27 +0000</resolved>
                                            <fixVersion>2.0.0-BETA3</fixVersion>
                                        <due></due>
                    <votes>3</votes>
                        <watches>2</watches>
                        <comments>
                    <comment id="10533" author="romanb" created="Sat, 7 Nov 2009 12:16:37 +0000"  >&lt;p&gt;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.&lt;/p&gt;

&lt;p&gt;sfDoctrine2Plugin already uses this logger for its debug toolbar.&lt;/p&gt;</comment>
                    <comment id="12614" author="hobodave" created="Sat, 10 Apr 2010 03:14:26 +0000"  >&lt;p&gt;Such timings are &lt;em&gt;very&lt;/em&gt; useful. The accuracy isn&apos;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 &quot;inaccurate&quot; time measurement you&apos;d be able to quickly identify the problem query(ies) and take further action.&lt;/p&gt;</comment>
                    <comment id="12952" author="romanb" created="Fri, 14 May 2010 08:47:06 +0000"  >&lt;p&gt;I think timings can be added.&lt;/p&gt;</comment>
                    <comment id="13303" author="beberlei" created="Sun, 13 Jun 2010 14:27:24 +0000"  >&lt;p&gt;Schedule for BETA 3&lt;/p&gt;</comment>
                    <comment id="13378" author="beberlei" created="Sun, 20 Jun 2010 10:52:27 +0000"  >&lt;p&gt;Implemented this change, the interface of the SQL Logger changed to:&lt;/p&gt;

&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-java&quot;&gt;function logSQL($sql, array $params = &lt;span class=&quot;code-keyword&quot;&gt;null&lt;/span&gt;, $executionMS = &lt;span class=&quot;code-keyword&quot;&gt;null&lt;/span&gt;);
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;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.&lt;/p&gt;</comment>
                </comments>
                    <attachments>
                </attachments>
            <subtasks>
        </subtasks>
        </item>
</channel>
</rss>