<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
		>
<channel>
	<title>Comments on: Fair Comparison</title>
	<atom:link href="http://jonathanlewis.wordpress.com/2010/08/29/fair-comparison/feed/" rel="self" type="application/rss+xml" />
	<link>http://jonathanlewis.wordpress.com/2010/08/29/fair-comparison/</link>
	<description>Just another Oracle weblog</description>
	<lastBuildDate>Sat, 18 May 2013 11:04:10 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
	<item>
		<title>By: Jonathan Lewis</title>
		<link>http://jonathanlewis.wordpress.com/2010/08/29/fair-comparison/#comment-37123</link>
		<dc:creator><![CDATA[Jonathan Lewis]]></dc:creator>
		<pubDate>Mon, 30 Aug 2010 14:22:02 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=4272#comment-37123</guid>
		<description><![CDATA[Flado,

Nice idea. It gets around the problem of the optimizer optimizing out redundant joins and column projections and getting different plans from the execution you&#039;d see in production.

With the PL/SQL optimizer constantly getting smarter, though, it would be interesting to see if PL/SQL eventually notices that you&#039;re not using data from the cursor inside the loop and starts rewriting the cursor statement.]]></description>
		<content:encoded><![CDATA[<p>Flado,</p>
<p>Nice idea. It gets around the problem of the optimizer optimizing out redundant joins and column projections and getting different plans from the execution you&#8217;d see in production.</p>
<p>With the PL/SQL optimizer constantly getting smarter, though, it would be interesting to see if PL/SQL eventually notices that you&#8217;re not using data from the cursor inside the loop and starts rewriting the cursor statement.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Flado</title>
		<link>http://jonathanlewis.wordpress.com/2010/08/29/fair-comparison/#comment-37121</link>
		<dc:creator><![CDATA[Flado]]></dc:creator>
		<pubDate>Mon, 30 Aug 2010 14:03:09 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=4272#comment-37121</guid>
		<description><![CDATA[Stew,
Yeah, re-working the script to use SYSTIMESTAMP, better interval formatting, and BULK COLLECT has been on my list for some time. On the other hand, a precision of 0.01 seconds is more than enough for the types of queries I test, the formatting works &quot;as is&quot; for elapsed times of 1 day or less, and nowadays PL/SQL does the array fetches for me, so...
It is by no means a clean experimental set-up, but it is nevertheless able to detect significant network throughput problems (or latency problems, if you do the AUTOTRACE TRACEONLY with a low array size),  and that&#039;s the only purpose I use it for.]]></description>
		<content:encoded><![CDATA[<p>Stew,<br />
Yeah, re-working the script to use SYSTIMESTAMP, better interval formatting, and BULK COLLECT has been on my list for some time. On the other hand, a precision of 0.01 seconds is more than enough for the types of queries I test, the formatting works &#8220;as is&#8221; for elapsed times of 1 day or less, and nowadays PL/SQL does the array fetches for me, so&#8230;<br />
It is by no means a clean experimental set-up, but it is nevertheless able to detect significant network throughput problems (or latency problems, if you do the AUTOTRACE TRACEONLY with a low array size),  and that&#8217;s the only purpose I use it for.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Stew Ashton</title>
		<link>http://jonathanlewis.wordpress.com/2010/08/29/fair-comparison/#comment-37119</link>
		<dc:creator><![CDATA[Stew Ashton]]></dc:creator>
		<pubDate>Mon, 30 Aug 2010 12:25:15 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=4272#comment-37119</guid>
		<description><![CDATA[Flado,

Good idea.  In addition to timing, this is a good way to run the query to completion in other tools than SQL*Plus.  I do this a lot in SQL Developer so I can run dbms_xplan.display_cursor afterwards.  I know there are equivalents to display_cursor in SQL Developer, but they can&#039;t be pasted easily into blog comments / asktom questions :)

Just a detail: Jonathan mentioned using different array sizes.  With your method, the array size will be either 1 (in 9i or before) or 100 (in 10g or later).]]></description>
		<content:encoded><![CDATA[<p>Flado,</p>
<p>Good idea.  In addition to timing, this is a good way to run the query to completion in other tools than SQL*Plus.  I do this a lot in SQL Developer so I can run dbms_xplan.display_cursor afterwards.  I know there are equivalents to display_cursor in SQL Developer, but they can&#8217;t be pasted easily into blog comments / asktom questions :)</p>
<p>Just a detail: Jonathan mentioned using different array sizes.  With your method, the array size will be either 1 (in 9i or before) or 100 (in 10g or later).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Flado</title>
		<link>http://jonathanlewis.wordpress.com/2010/08/29/fair-comparison/#comment-37115</link>
		<dc:creator><![CDATA[Flado]]></dc:creator>
		<pubDate>Mon, 30 Aug 2010 07:34:17 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=4272#comment-37115</guid>
		<description><![CDATA[I also found it useful to compare the elapsed time I get using &quot;autotrace traceonly&quot; to the elapsed time reported by my testview.sql script (below). The script gives me pure database time (first row and last row), and the comparison to &quot;autotrace traceonly&quot; yields the network transfer time.
It might be nitpicking, but I think it&#039;s always worth pointing out that &quot;last row&quot; timing includes the time needed to check that there are no more rows to return.
Here&#039;s the script. It&#039;s pretty old (8i), which explains the &#039;manual&#039; interval formatting. The only argument is the name of a file containing the query under test. &quot;@&amp;viewname&quot; *must* be on a line by itself, with no leading whitespace.
[sourcecode]
define viewname=&amp;1
set serverout on size 100000
set timi on
declare
    i integer:=0;
    stt number;
	rsp number;
begin
	stt:=dbms_utility.get_time;
    for bz in (
@&amp;viewname
) loop
	if rsp is null then rsp:=dbms_utility.get_time-stt; end if;
        i:=i+1;
    end loop;
    stt:=dbms_utility.get_time-stt;
    dbms_output.put_line(substr(&#039;Count: &#039;&#124;&#124;i,1,255));
    dbms_output.put_line(&#039;Elapsed:	&#039;&#124;&#124;
        to_char(trunc(sysdate)+trunc(stt/100)/3600/24,&#039;HH24:MI:SS&#039;)&#124;&#124;&#039;.&#039;&#124;&#124;
        ltrim(to_char(mod(stt,100),&#039;00&#039;))
    );
    dbms_output.put_line(&#039;First row:	&#039;&#124;&#124;
        to_char(trunc(sysdate)+trunc(rsp/100)/3600/24,&#039;HH24:MI:SS&#039;)&#124;&#124;&#039;.&#039;&#124;&#124;
        ltrim(to_char(mod(rsp,100),&#039;00&#039;))
    );
end;
/
[/sourcecode]]]></description>
		<content:encoded><![CDATA[<p>I also found it useful to compare the elapsed time I get using &#8220;autotrace traceonly&#8221; to the elapsed time reported by my testview.sql script (below). The script gives me pure database time (first row and last row), and the comparison to &#8220;autotrace traceonly&#8221; yields the network transfer time.<br />
It might be nitpicking, but I think it&#8217;s always worth pointing out that &#8220;last row&#8221; timing includes the time needed to check that there are no more rows to return.<br />
Here&#8217;s the script. It&#8217;s pretty old (8i), which explains the &#8216;manual&#8217; interval formatting. The only argument is the name of a file containing the query under test. &#8220;@&amp;viewname&#8221; *must* be on a line by itself, with no leading whitespace.</p>
<pre class="brush: plain; title: ; notranslate">
define viewname=&amp;1
set serverout on size 100000
set timi on
declare
    i integer:=0;
    stt number;
	rsp number;
begin
	stt:=dbms_utility.get_time;
    for bz in (
@&amp;viewname
) loop
	if rsp is null then rsp:=dbms_utility.get_time-stt; end if;
        i:=i+1;
    end loop;
    stt:=dbms_utility.get_time-stt;
    dbms_output.put_line(substr('Count: '||i,1,255));
    dbms_output.put_line('Elapsed:	'||
        to_char(trunc(sysdate)+trunc(stt/100)/3600/24,'HH24:MI:SS')||'.'||
        ltrim(to_char(mod(stt,100),'00'))
    );
    dbms_output.put_line('First row:	'||
        to_char(trunc(sysdate)+trunc(rsp/100)/3600/24,'HH24:MI:SS')||'.'||
        ltrim(to_char(mod(rsp,100),'00'))
    );
end;
/
</pre>
]]></content:encoded>
	</item>
</channel>
</rss>
