<?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: Quiz Night</title>
	<atom:link href="http://jonathanlewis.wordpress.com/2009/08/28/quiz-night-2/feed/" rel="self" type="application/rss+xml" />
	<link>http://jonathanlewis.wordpress.com/2009/08/28/quiz-night-2/</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/2009/08/28/quiz-night-2/#comment-34969</link>
		<dc:creator><![CDATA[Jonathan Lewis]]></dc:creator>
		<pubDate>Sat, 12 Dec 2009 11:23:18 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=2023#comment-34969</guid>
		<description><![CDATA[Chris,

I think Timur has answered your question about using the &quot;pseudo&quot; hint.  

There was a problem in some older versions of Oracle where pl/sql lost the hints if you failed to leave a space between the &quot;+&quot; and the first word of the hint, though; and I think there was a more recent (but still pre-10g) version of one of the ODBC or JDBC drivers that managed to strip hints out of code in transit.]]></description>
		<content:encoded><![CDATA[<p>Chris,</p>
<p>I think Timur has answered your question about using the &#8220;pseudo&#8221; hint.  </p>
<p>There was a problem in some older versions of Oracle where pl/sql lost the hints if you failed to leave a space between the &#8220;+&#8221; and the first word of the hint, though; and I think there was a more recent (but still pre-10g) version of one of the ODBC or JDBC drivers that managed to strip hints out of code in transit.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Timur Akhmadeev</title>
		<link>http://jonathanlewis.wordpress.com/2009/08/28/quiz-night-2/#comment-34953</link>
		<dc:creator><![CDATA[Timur Akhmadeev]]></dc:creator>
		<pubDate>Mon, 07 Dec 2009 08:09:58 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=2023#comment-34953</guid>
		<description><![CDATA[It will work in PL/SQL too since PL wouldn&#039;t remove the comment if it looked like a hint. The problem with such a technique is to support many different versions of the same code.]]></description>
		<content:encoded><![CDATA[<p>It will work in PL/SQL too since PL wouldn&#8217;t remove the comment if it looked like a hint. The problem with such a technique is to support many different versions of the same code.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chris</title>
		<link>http://jonathanlewis.wordpress.com/2009/08/28/quiz-night-2/#comment-34951</link>
		<dc:creator><![CDATA[Chris]]></dc:creator>
		<pubDate>Sun, 06 Dec 2009 05:57:56 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=2023#comment-34951</guid>
		<description><![CDATA[Neat - is there a way to take advantage of this in PL/SQL?]]></description>
		<content:encoded><![CDATA[<p>Neat &#8211; is there a way to take advantage of this in PL/SQL?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Log Buffer #160: a Carnival of the Vanities for DBAs &#124; Pythian Group Blog</title>
		<link>http://jonathanlewis.wordpress.com/2009/08/28/quiz-night-2/#comment-34321</link>
		<dc:creator><![CDATA[Log Buffer #160: a Carnival of the Vanities for DBAs &#124; Pythian Group Blog]]></dc:creator>
		<pubDate>Fri, 04 Sep 2009 17:00:28 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=2023#comment-34321</guid>
		<description><![CDATA[[...] the Oracle Scratchpad, it was quiz night again. In this second one, Jonathan Lewis and his contestants submit their explanations for bundle [...]]]></description>
		<content:encoded><![CDATA[<p>[...] the Oracle Scratchpad, it was quiz night again. In this second one, Jonathan Lewis and his contestants submit their explanations for bundle [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: mwidlake</title>
		<link>http://jonathanlewis.wordpress.com/2009/08/28/quiz-night-2/#comment-34278</link>
		<dc:creator><![CDATA[mwidlake]]></dc:creator>
		<pubDate>Tue, 01 Sep 2009 20:32:50 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=2023#comment-34278</guid>
		<description><![CDATA[&quot;I’m going to pick up mwidlake for an error &quot; - Ahh Damn, I&#039;m going to stop trying!
No I&#039;m not really, and I&#039;m happy to have my mistakes picked up. Yes, the statement has to give exactly the same hash value, ie be byte-by-byte the same. Even lower/upper case and extra spaces create a different entry so my stupid mistake.

I like Piet&#039;s point further down - OK, so it was generating lots of hard parses, but was it causing an impact to the business? Was there a gain by fixing it? I suspect yes, but Piet&#039;s question is perhaps the core of &quot;Why to Tune&quot;.

Moha&#039;s point was very good. I like that.]]></description>
		<content:encoded><![CDATA[<p>&#8220;I’m going to pick up mwidlake for an error &#8221; &#8211; Ahh Damn, I&#8217;m going to stop trying!<br />
No I&#8217;m not really, and I&#8217;m happy to have my mistakes picked up. Yes, the statement has to give exactly the same hash value, ie be byte-by-byte the same. Even lower/upper case and extra spaces create a different entry so my stupid mistake.</p>
<p>I like Piet&#8217;s point further down &#8211; OK, so it was generating lots of hard parses, but was it causing an impact to the business? Was there a gain by fixing it? I suspect yes, but Piet&#8217;s question is perhaps the core of &#8220;Why to Tune&#8221;.</p>
<p>Moha&#8217;s point was very good. I like that.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jonathan Lewis</title>
		<link>http://jonathanlewis.wordpress.com/2009/08/28/quiz-night-2/#comment-34277</link>
		<dc:creator><![CDATA[Jonathan Lewis]]></dc:creator>
		<pubDate>Tue, 01 Sep 2009 18:07:04 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=2023#comment-34277</guid>
		<description><![CDATA[lascoltodelvenerdi,
Point taken - I should have been more precise: &lt;i&gt;&quot;if DDL in a loop is actually happening in production as part of a lightweight end-user facing operation ... &quot;&lt;/i&gt;.

Housekeeping code - particularly code for partition maintenance - could reasonably loop through DDL: I&#039;ve event implemented that type of thing myself.]]></description>
		<content:encoded><![CDATA[<p>lascoltodelvenerdi,<br />
Point taken &#8211; I should have been more precise: <i>&#8220;if DDL in a loop is actually happening in production as part of a lightweight end-user facing operation &#8230; &#8220;</i>.</p>
<p>Housekeeping code &#8211; particularly code for partition maintenance &#8211; could reasonably loop through DDL: I&#8217;ve event implemented that type of thing myself.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: PdV</title>
		<link>http://jonathanlewis.wordpress.com/2009/08/28/quiz-night-2/#comment-34276</link>
		<dc:creator><![CDATA[PdV]]></dc:creator>
		<pubDate>Tue, 01 Sep 2009 16:32:43 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=2023#comment-34276</guid>
		<description><![CDATA[The use of comment or other way to uniquely identify (find, trace) a statement can be quite handy and it would have been my guess. But it turned out to be a totally un-glamorous oversight then.
The simplest explanation eh ?

If Dynamic-SQL or parsing seems a problem, I tend to look for nr of statements using the same plan to spot possible problem-stmnts. I suspect (nearly) all stmnts had the same plan, but did they ?
And you mention the relatively high number of 30 stmnts in 60 seconds and &quot;causing hard parse on every statement&quot;. But was parsing (or CPU usage, or shared-pool) acutally a problem on this system ?]]></description>
		<content:encoded><![CDATA[<p>The use of comment or other way to uniquely identify (find, trace) a statement can be quite handy and it would have been my guess. But it turned out to be a totally un-glamorous oversight then.<br />
The simplest explanation eh ?</p>
<p>If Dynamic-SQL or parsing seems a problem, I tend to look for nr of statements using the same plan to spot possible problem-stmnts. I suspect (nearly) all stmnts had the same plan, but did they ?<br />
And you mention the relatively high number of 30 stmnts in 60 seconds and &#8220;causing hard parse on every statement&#8221;. But was parsing (or CPU usage, or shared-pool) acutally a problem on this system ?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mohamed Houri</title>
		<link>http://jonathanlewis.wordpress.com/2009/08/28/quiz-night-2/#comment-34275</link>
		<dc:creator><![CDATA[Mohamed Houri]]></dc:creator>
		<pubDate>Tue, 01 Sep 2009 07:53:41 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=2023#comment-34275</guid>
		<description><![CDATA[a DDL(such as Truncate) in a Loop induces an implicit commit; commit inside the loop(or commit across fetch) represents one of the main reasons for ora-01555 rollback segment snapshot too old.]]></description>
		<content:encoded><![CDATA[<p>a DDL(such as Truncate) in a Loop induces an implicit commit; commit inside the loop(or commit across fetch) represents one of the main reasons for ora-01555 rollback segment snapshot too old.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: lascoltodelvenerdi</title>
		<link>http://jonathanlewis.wordpress.com/2009/08/28/quiz-night-2/#comment-34274</link>
		<dc:creator><![CDATA[lascoltodelvenerdi]]></dc:creator>
		<pubDate>Tue, 01 Sep 2009 06:39:28 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=2023#comment-34274</guid>
		<description><![CDATA[@Jonathan
&quot;If DDL in the loop is actually happening in production it definitely an error that should be corrected.&quot;

Well, it&#039;s not a rule.

I&#039;m working in a project where we must create table partitions or &quot;swap tables&quot; on the fly so we have many loops where you can see &quot;add partitions&quot; or &quot;create tables&quot;.

It&#039;s the only way to do it because partitions and &quot;swap tables&quot; depends on data (i.e. we have things like &quot;partition by sysdate&quot;)

So a DDL in a loop can be OK.

Bye,
Antonio]]></description>
		<content:encoded><![CDATA[<p>@Jonathan<br />
&#8220;If DDL in the loop is actually happening in production it definitely an error that should be corrected.&#8221;</p>
<p>Well, it&#8217;s not a rule.</p>
<p>I&#8217;m working in a project where we must create table partitions or &#8220;swap tables&#8221; on the fly so we have many loops where you can see &#8220;add partitions&#8221; or &#8220;create tables&#8221;.</p>
<p>It&#8217;s the only way to do it because partitions and &#8220;swap tables&#8221; depends on data (i.e. we have things like &#8220;partition by sysdate&#8221;)</p>
<p>So a DDL in a loop can be OK.</p>
<p>Bye,<br />
Antonio</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jonathan Lewis</title>
		<link>http://jonathanlewis.wordpress.com/2009/08/28/quiz-night-2/#comment-34273</link>
		<dc:creator><![CDATA[Jonathan Lewis]]></dc:creator>
		<pubDate>Mon, 31 Aug 2009 19:58:26 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=2023#comment-34273</guid>
		<description><![CDATA[Whenever I see something a little unusual, I usually ask myself: &quot;why might that happen - why would anyone &lt;b&gt;&lt;i&gt;want&lt;/i&gt;&lt;/b&gt; to do that ?&quot; If you don&#039;t get into this habit you can easily end up wasting time trying to fix something that isn&#039;t broken.

My question was deliberately a little vague and open-ended because I didn&#039;t want to push people in any particular direction - I just wanted them to prompt their imagination.

Before I tell you the idea I had to justify this odd pattern, I&#039;ll just commment on a few of the suggestions.

First the people who tried to explain the phenomenont:

Ceninual (#1) and others:  when I pointed this out to the on-site DBA, his comment was: &quot;It looks like they&#039;re using the customer ID as the name of the bind variable.&quot;  So full marks for good guesswork - and Dave&#039;s comment (#3) helps to explain why it sounds like a nice idea - but this isn&#039;t a reasonable &lt;b&gt;justification&lt;/b&gt; for what they&#039;ve done, and in this case the developers need a proper explanation of why bind variables are important.

Charles&#039; comment (#4) is worth a mention because it is possible that some programming enviroment could be responsible for an unexpected and undeirable pattern of behaviour - and Joel&#039;s follow-up in #5 is an interesting extension of that thought, does the process ID appear in the bind variable somehow ... the &quot;multiple schema&quot; idea appearing in a later post also ties in here, as it might be one variable name per schema.  (But it&#039;s not a pl/sql thing - a couple of the other comments reminds us that pl/sql turns variable names into :Bnnn, where the nnn represents a numeric value).

I&#039;m going to pick up mwidlake for an error - because we often learn from other people&#039;s mistakes. If two pieces of SQL look different they will appear in the library cache (x$kglob) as different parent objects, and different parents will have different children. So if the texts look the same apart from the &quot;:v_NNNNNN&quot; then each text is a different parent with a child holding the execution plan.




Chen (#2): again a possibility - DDL inside the loop - but a little unlikely and not a good justification for what&#039;s going on.  If DDL in the loop is actually happening in production it&#039;s definitely an error &lt;em&gt;[but see comment #18]&lt;/em&gt; that should be corrected. (Although global temporary tables could be an exception, and did produce some catastrophic effects in earlier versionsof Oracle).  A table name of &lt;b&gt;customers&lt;/b&gt; makes DDL a little unlikely though.


A throwaway comment about primary keys and histograms - depending on the nature of the key and the queries, a histogram can be relevant to a PK if the &lt;b&gt;values&lt;/b&gt; have an odd distribution, even if the &lt;b&gt;frequencies&lt;/b&gt; do not. In this case, though, the nature of the query (customer by ID) seems to suggest that there is no intention of avoiding problems of data skew.

There was some discussion about different technologies, or function features, and their effects on how cursor caching and library cache contention may be affected - this type of discussion is important and Oracle has changed all sorts of details of cursor caching and cursor pinning over the versions from 8i to 10g, so it&#039;s always worth testing your old coding ideas each time you start a new project.

Finally we come to the thought I had - and it&#039;s very close to the idea from Moha (#11) about deliberately making identical queries look (slightly) different to avoid library cache latch contention.

The client has 32 web application servers addressing a single database. If this is a very popular query then the single library cache latch protecting a totally sharable query could get hammered and be the focus of a lot of library cache latch contention. In the past when I&#039;ve seen this happening I&#039;ve advised clients to introduce a mechanism that makes each application server use &quot;different&quot; SQL by creating SQL that includes a &quot;hint&quot; like: &lt;b&gt;&lt;i&gt;/*+ from WAS 23 */&lt;/i&gt;&lt;/b&gt;

Could it be that this client had done the same sort of thing - but made the SQL look different by generating variable names that were dependent in some way on the identity of the Web application server sending in the query ?

(In this case the answer was no - because every single query was executed just once, and they really were using the input value as the name of the bind variable.  The DBA has since explained to them the reason why bind variable are good - but only if your bind variable names don&#039;t keep changing).

Apologies for any typos - I&#039;m on a three-hour train journey and the Wifi link keeps dropping.]]></description>
		<content:encoded><![CDATA[<p>Whenever I see something a little unusual, I usually ask myself: &#8220;why might that happen &#8211; why would anyone <b><i>want</i></b> to do that ?&#8221; If you don&#8217;t get into this habit you can easily end up wasting time trying to fix something that isn&#8217;t broken.</p>
<p>My question was deliberately a little vague and open-ended because I didn&#8217;t want to push people in any particular direction &#8211; I just wanted them to prompt their imagination.</p>
<p>Before I tell you the idea I had to justify this odd pattern, I&#8217;ll just commment on a few of the suggestions.</p>
<p>First the people who tried to explain the phenomenont:</p>
<p>Ceninual (#1) and others:  when I pointed this out to the on-site DBA, his comment was: &#8220;It looks like they&#8217;re using the customer ID as the name of the bind variable.&#8221;  So full marks for good guesswork &#8211; and Dave&#8217;s comment (#3) helps to explain why it sounds like a nice idea &#8211; but this isn&#8217;t a reasonable <b>justification</b> for what they&#8217;ve done, and in this case the developers need a proper explanation of why bind variables are important.</p>
<p>Charles&#8217; comment (#4) is worth a mention because it is possible that some programming enviroment could be responsible for an unexpected and undeirable pattern of behaviour &#8211; and Joel&#8217;s follow-up in #5 is an interesting extension of that thought, does the process ID appear in the bind variable somehow &#8230; the &#8220;multiple schema&#8221; idea appearing in a later post also ties in here, as it might be one variable name per schema.  (But it&#8217;s not a pl/sql thing &#8211; a couple of the other comments reminds us that pl/sql turns variable names into :Bnnn, where the nnn represents a numeric value).</p>
<p>I&#8217;m going to pick up mwidlake for an error &#8211; because we often learn from other people&#8217;s mistakes. If two pieces of SQL look different they will appear in the library cache (x$kglob) as different parent objects, and different parents will have different children. So if the texts look the same apart from the &#8220;:v_NNNNNN&#8221; then each text is a different parent with a child holding the execution plan.</p>
<p>Chen (#2): again a possibility &#8211; DDL inside the loop &#8211; but a little unlikely and not a good justification for what&#8217;s going on.  If DDL in the loop is actually happening in production it&#8217;s definitely an error <em>[but see comment #18]</em> that should be corrected. (Although global temporary tables could be an exception, and did produce some catastrophic effects in earlier versionsof Oracle).  A table name of <b>customers</b> makes DDL a little unlikely though.</p>
<p>A throwaway comment about primary keys and histograms &#8211; depending on the nature of the key and the queries, a histogram can be relevant to a PK if the <b>values</b> have an odd distribution, even if the <b>frequencies</b> do not. In this case, though, the nature of the query (customer by ID) seems to suggest that there is no intention of avoiding problems of data skew.</p>
<p>There was some discussion about different technologies, or function features, and their effects on how cursor caching and library cache contention may be affected &#8211; this type of discussion is important and Oracle has changed all sorts of details of cursor caching and cursor pinning over the versions from 8i to 10g, so it&#8217;s always worth testing your old coding ideas each time you start a new project.</p>
<p>Finally we come to the thought I had &#8211; and it&#8217;s very close to the idea from Moha (#11) about deliberately making identical queries look (slightly) different to avoid library cache latch contention.</p>
<p>The client has 32 web application servers addressing a single database. If this is a very popular query then the single library cache latch protecting a totally sharable query could get hammered and be the focus of a lot of library cache latch contention. In the past when I&#8217;ve seen this happening I&#8217;ve advised clients to introduce a mechanism that makes each application server use &#8220;different&#8221; SQL by creating SQL that includes a &#8220;hint&#8221; like: <b><i>/*+ from WAS 23 */</i></b></p>
<p>Could it be that this client had done the same sort of thing &#8211; but made the SQL look different by generating variable names that were dependent in some way on the identity of the Web application server sending in the query ?</p>
<p>(In this case the answer was no &#8211; because every single query was executed just once, and they really were using the input value as the name of the bind variable.  The DBA has since explained to them the reason why bind variable are good &#8211; but only if your bind variable names don&#8217;t keep changing).</p>
<p>Apologies for any typos &#8211; I&#8217;m on a three-hour train journey and the Wifi link keeps dropping.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
