<?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/"
		>
<channel>
	<title>Comments on: 60000 bind variables?! Maybe it&#8217;s time to use a temporary table instead&#8230;</title>
	<atom:link href="http://blog.tanelpoder.com/2009/02/25/60000-bind-variables-maybe-its-time-to-use-a-temporary-table-instead/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.tanelpoder.com/2009/02/25/60000-bind-variables-maybe-its-time-to-use-a-temporary-table-instead/</link>
	<description>Oracle troubleshooting, internals and performance tuning</description>
	<lastBuildDate>Thu, 09 Sep 2010 21:02:01 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
	<item>
		<title>By: kiran</title>
		<link>http://blog.tanelpoder.com/2009/02/25/60000-bind-variables-maybe-its-time-to-use-a-temporary-table-instead/comment-page-1/#comment-2726</link>
		<dc:creator>kiran</dc:creator>
		<pubDate>Fri, 09 Oct 2009 07:41:29 +0000</pubDate>
		<guid isPermaLink="false">http://blog.tanelpoder.com/?p=229#comment-2726</guid>
		<description>SELECT TYRE_SPEC_DESC,INITCAP(VEN_DESC) VEN_DESC,
  COUNT(DECODE(range_wise,1,range_wise,NULL ) ) AS &quot;0-1000&quot;,
  COUNT(DECODE(range_wise,3,range_wise,NULL ) ) AS &quot;1001-3000&quot;,
  COUNT(DECODE(range_wise,5,range_wise,NULL ) ) AS &quot;3001-5000&quot;,
  COUNT(DECODE(range_wise,7,range_wise,NULL ) ) AS &quot;5001-7000&quot;,
  COUNT(DECODE(range_wise,9,range_wise,NULL ) ) AS &quot;7001-9000&quot;,
  COUNT(DECODE(range_wise,10,range_wise,NULL ) ) AS &quot;9000 and above&quot;,
   COUNT(DECODE(range_wise,11,range_wise,0 ) ) AS &quot;total&quot;
  FROM (
SELECT TYRE_SPEC_DESC,INITCAP(VEN_DESC) VEN_DESC,subasm_sl_num,cumm_hours,range_wise FROM 
 (select SUBASM_SL_NUM,sum(decode(rmvl_flag,&#039;Y&#039;,(hmr_off-hmr_on),(b.hmr-hmr_on))) cumm_hours from  OCC_SUBASM_HSTRY_TRN a,
occ_eqpt_hmr_trn b,occ_subasm_mst c,OCC_TYRE_CLS_MST d,OCJ_VEN_MST E,OCC_TYRE_SPEC_MST F
where  a.subasm_id=c.SUBASM_ID and a.eqpt_id=b.eqpt_id and c.SUBASM_NAME_ID=52 and a.SUBASM_NAME_ID=c.SUBASM_NAME_ID and
  D.VEN_ID=E.VEN_ID  AND F.TYRE_SPEC_TYPE_ID = 1 and D.SIZE_ID = F.TYRE_SPEC_ID  AND D.ACTIVE_FLAG=&#039;Y&#039; 
  and  c.SUBASM_MDL_ID=d.CLS_ID and FTMT_DATE &#039;07-oct-2009&#039; OR RMVL_DATE IS NULL  )
  and b.trn_date=(select max(trn_date) from occ_eqpt_hmr_trn where eqpt_id=a.eqpt_id and trn_date=9001]=10)) 
GROUP BY TYRE_SPEC_DESC,VEN_DESC</description>
		<content:encoded><![CDATA[<p>SELECT TYRE_SPEC_DESC,INITCAP(VEN_DESC) VEN_DESC,<br />
  COUNT(DECODE(range_wise,1,range_wise,NULL ) ) AS &#8220;0-1000&#8243;,<br />
  COUNT(DECODE(range_wise,3,range_wise,NULL ) ) AS &#8220;1001-3000&#8243;,<br />
  COUNT(DECODE(range_wise,5,range_wise,NULL ) ) AS &#8220;3001-5000&#8243;,<br />
  COUNT(DECODE(range_wise,7,range_wise,NULL ) ) AS &#8220;5001-7000&#8243;,<br />
  COUNT(DECODE(range_wise,9,range_wise,NULL ) ) AS &#8220;7001-9000&#8243;,<br />
  COUNT(DECODE(range_wise,10,range_wise,NULL ) ) AS &#8220;9000 and above&#8221;,<br />
   COUNT(DECODE(range_wise,11,range_wise,0 ) ) AS &#8220;total&#8221;<br />
  FROM (<br />
SELECT TYRE_SPEC_DESC,INITCAP(VEN_DESC) VEN_DESC,subasm_sl_num,cumm_hours,range_wise FROM<br />
 (select SUBASM_SL_NUM,sum(decode(rmvl_flag,&#8217;Y',(hmr_off-hmr_on),(b.hmr-hmr_on))) cumm_hours from  OCC_SUBASM_HSTRY_TRN a,<br />
occ_eqpt_hmr_trn b,occ_subasm_mst c,OCC_TYRE_CLS_MST d,OCJ_VEN_MST E,OCC_TYRE_SPEC_MST F<br />
where  a.subasm_id=c.SUBASM_ID and a.eqpt_id=b.eqpt_id and c.SUBASM_NAME_ID=52 and a.SUBASM_NAME_ID=c.SUBASM_NAME_ID and<br />
  D.VEN_ID=E.VEN_ID  AND F.TYRE_SPEC_TYPE_ID = 1 and D.SIZE_ID = F.TYRE_SPEC_ID  AND D.ACTIVE_FLAG=&#8217;Y&#8217;<br />
  and  c.SUBASM_MDL_ID=d.CLS_ID and FTMT_DATE &#8217;07-oct-2009&#8242; OR RMVL_DATE IS NULL  )<br />
  and b.trn_date=(select max(trn_date) from occ_eqpt_hmr_trn where eqpt_id=a.eqpt_id and trn_date=9001]=10))<br />
GROUP BY TYRE_SPEC_DESC,VEN_DESC</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Oraboy</title>
		<link>http://blog.tanelpoder.com/2009/02/25/60000-bind-variables-maybe-its-time-to-use-a-temporary-table-instead/comment-page-1/#comment-1084</link>
		<dc:creator>Oraboy</dc:creator>
		<pubDate>Sun, 01 Mar 2009 16:59:07 +0000</pubDate>
		<guid isPermaLink="false">http://blog.tanelpoder.com/?p=229#comment-1084</guid>
		<description>&gt;&gt;That’s about 100 times more bind variables in a single query than what I’ve seen in past. And I thought that query was bad!!! :)

You may be interested in checking this query out..

http://oracleisfun.blogspot.com/2008/04/sql-goes-object-oriented-way.html</description>
		<content:encoded><![CDATA[<p>&gt;&gt;That’s about 100 times more bind variables in a single query than what I’ve seen in past. And I thought that query was bad!!! :)</p>
<p>You may be interested in checking this query out..</p>
<p><a href="http://oracleisfun.blogspot.com/2008/04/sql-goes-object-oriented-way.html" rel="nofollow">http://oracleisfun.blogspot.com/2008/04/sql-goes-object-oriented-way.html</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Havard</title>
		<link>http://blog.tanelpoder.com/2009/02/25/60000-bind-variables-maybe-its-time-to-use-a-temporary-table-instead/comment-page-1/#comment-1079</link>
		<dc:creator>Havard</dc:creator>
		<pubDate>Sat, 28 Feb 2009 19:17:40 +0000</pubDate>
		<guid isPermaLink="false">http://blog.tanelpoder.com/?p=229#comment-1079</guid>
		<description>Tanel:

Thank you for the clarification, greatly appreciate it :-) Keep up the good work!</description>
		<content:encoded><![CDATA[<p>Tanel:</p>
<p>Thank you for the clarification, greatly appreciate it :-) Keep up the good work!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alexis Gil Gonzales</title>
		<link>http://blog.tanelpoder.com/2009/02/25/60000-bind-variables-maybe-its-time-to-use-a-temporary-table-instead/comment-page-1/#comment-1078</link>
		<dc:creator>Alexis Gil Gonzales</dc:creator>
		<pubDate>Sat, 28 Feb 2009 12:38:55 +0000</pubDate>
		<guid isPermaLink="false">http://blog.tanelpoder.com/?p=229#comment-1078</guid>
		<description>Hi Tanel,

I&#039;ve seen that kind of weirdo, though not that massive, in Hibernate-generated code on a large java project.  (yes, hard to clear out the myth that Oracle=JADS :-) ).</description>
		<content:encoded><![CDATA[<p>Hi Tanel,</p>
<p>I&#8217;ve seen that kind of weirdo, though not that massive, in Hibernate-generated code on a large java project.  (yes, hard to clear out the myth that Oracle=JADS :-) ).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tanel Poder</title>
		<link>http://blog.tanelpoder.com/2009/02/25/60000-bind-variables-maybe-its-time-to-use-a-temporary-table-instead/comment-page-1/#comment-1076</link>
		<dc:creator>Tanel Poder</dc:creator>
		<pubDate>Sat, 28 Feb 2009 09:19:08 +0000</pubDate>
		<guid isPermaLink="false">http://blog.tanelpoder.com/?p=229#comment-1076</guid>
		<description>Hi Havard,

The GTT data blocks are kept in buffer cache, as opposed to UGA memory.
DBWR may flush these blocks to corresponding temp segments in temp tablespace if there&#039;s a need.

If the GTT data is reset fast enough (and there&#039;s no buffer cache pressure) then the GTT blocks don&#039;t get written to temp at all.

So, if you need to push such big number of inlist values, you have following tradeoffs:

1) code all bind variables into SQL text. This will take time in parsing and binding phase. Also it will need memory from shared pool, possibly flushes out lots of other stuff

2) use GTTs for passing in bind variables. SQL text is simple, but you have overhead of inserting into GTT. also you should reset the GTT contents after using if you don&#039;t want DBWR to write it to temp

3) use a PL/SQL array for passing in bind list. SQL text is again simple, however the inlists are kept in process private memory. Nowadays (since 9i+) processes can release private memory back to OS so it may not be that much of a problem.

So, it&#039;s a tradeoff. I would go with either PL/SQL collections or GTTs.</description>
		<content:encoded><![CDATA[<p>Hi Havard,</p>
<p>The GTT data blocks are kept in buffer cache, as opposed to UGA memory.<br />
DBWR may flush these blocks to corresponding temp segments in temp tablespace if there&#8217;s a need.</p>
<p>If the GTT data is reset fast enough (and there&#8217;s no buffer cache pressure) then the GTT blocks don&#8217;t get written to temp at all.</p>
<p>So, if you need to push such big number of inlist values, you have following tradeoffs:</p>
<p>1) code all bind variables into SQL text. This will take time in parsing and binding phase. Also it will need memory from shared pool, possibly flushes out lots of other stuff</p>
<p>2) use GTTs for passing in bind variables. SQL text is simple, but you have overhead of inserting into GTT. also you should reset the GTT contents after using if you don&#8217;t want DBWR to write it to temp</p>
<p>3) use a PL/SQL array for passing in bind list. SQL text is again simple, however the inlists are kept in process private memory. Nowadays (since 9i+) processes can release private memory back to OS so it may not be that much of a problem.</p>
<p>So, it&#8217;s a tradeoff. I would go with either PL/SQL collections or GTTs.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Havard</title>
		<link>http://blog.tanelpoder.com/2009/02/25/60000-bind-variables-maybe-its-time-to-use-a-temporary-table-instead/comment-page-1/#comment-1073</link>
		<dc:creator>Havard</dc:creator>
		<pubDate>Fri, 27 Feb 2009 13:07:31 +0000</pubDate>
		<guid isPermaLink="false">http://blog.tanelpoder.com/?p=229#comment-1073</guid>
		<description>Tanel: I thought gtt&#039;s was flushed to TEMP tablespace at some point? 

From AskTom: &quot;Temporary data files (temp files) in Oracle are a special type of data file. Oracle will use 
temporary files to store the intermediate results of a large sort operation, hash operations, 
global temporary table data, or result set, when there is insufficient memory to hold it all in 
RAM.&quot;

I&#039;m no expert on this, but I once witnessed severe downgrade in performance when gtt&#039;s grew for some users.

Can you spare some time to educate me (us?) on the pros and cons for using gtt as opposed to PL/SQL collections (SGA/PGA)? When will a gtt be flushed from buffer cache (same as ordinary table data?)?

I would greatly appreciate your input :-)</description>
		<content:encoded><![CDATA[<p>Tanel: I thought gtt&#8217;s was flushed to TEMP tablespace at some point? </p>
<p>From AskTom: &#8220;Temporary data files (temp files) in Oracle are a special type of data file. Oracle will use<br />
temporary files to store the intermediate results of a large sort operation, hash operations,<br />
global temporary table data, or result set, when there is insufficient memory to hold it all in<br />
RAM.&#8221;</p>
<p>I&#8217;m no expert on this, but I once witnessed severe downgrade in performance when gtt&#8217;s grew for some users.</p>
<p>Can you spare some time to educate me (us?) on the pros and cons for using gtt as opposed to PL/SQL collections (SGA/PGA)? When will a gtt be flushed from buffer cache (same as ordinary table data?)?</p>
<p>I would greatly appreciate your input :-)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: joel garry</title>
		<link>http://blog.tanelpoder.com/2009/02/25/60000-bind-variables-maybe-its-time-to-use-a-temporary-table-instead/comment-page-1/#comment-1066</link>
		<dc:creator>joel garry</dc:creator>
		<pubDate>Thu, 26 Feb 2009 19:26:38 +0000</pubDate>
		<guid isPermaLink="false">http://blog.tanelpoder.com/?p=229#comment-1066</guid>
		<description>My cynical speculation:  Maybe someone was just getting tired of hp-ux itanium being the redheaded stepchild, wanted to force Oracle to look at otherwise difficult to reproduce shared pool fragmentation errors.  And then escalated after &quot;upgrade to 10.2.0.4.&quot;  :-O</description>
		<content:encoded><![CDATA[<p>My cynical speculation:  Maybe someone was just getting tired of hp-ux itanium being the redheaded stepchild, wanted to force Oracle to look at otherwise difficult to reproduce shared pool fragmentation errors.  And then escalated after &#8220;upgrade to 10.2.0.4.&#8221;  :-O</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tanel Poder</title>
		<link>http://blog.tanelpoder.com/2009/02/25/60000-bind-variables-maybe-its-time-to-use-a-temporary-table-instead/comment-page-1/#comment-1062</link>
		<dc:creator>Tanel Poder</dc:creator>
		<pubDate>Thu, 26 Feb 2009 14:53:40 +0000</pubDate>
		<guid isPermaLink="false">http://blog.tanelpoder.com/?p=229#comment-1062</guid>
		<description>GTT blocks are also cached in buffer cache, there will be no disk swapping.

It&#039;s always a tradeoff, if you don&#039;t use a GTT or PL/SQL collection you will spend more time parsing and also flush out other objects from shared pool...</description>
		<content:encoded><![CDATA[<p>GTT blocks are also cached in buffer cache, there will be no disk swapping.</p>
<p>It&#8217;s always a tradeoff, if you don&#8217;t use a GTT or PL/SQL collection you will spend more time parsing and also flush out other objects from shared pool&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Havard</title>
		<link>http://blog.tanelpoder.com/2009/02/25/60000-bind-variables-maybe-its-time-to-use-a-temporary-table-instead/comment-page-1/#comment-1060</link>
		<dc:creator>Havard</dc:creator>
		<pubDate>Thu, 26 Feb 2009 09:39:36 +0000</pubDate>
		<guid isPermaLink="false">http://blog.tanelpoder.com/?p=229#comment-1060</guid>
		<description>Hm... 60,000 rows is a GTT. Got to be careful with that, you REALLY don&#039;t want disk swapping in a busy production environment.</description>
		<content:encoded><![CDATA[<p>Hm&#8230; 60,000 rows is a GTT. Got to be careful with that, you REALLY don&#8217;t want disk swapping in a busy production environment.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rick</title>
		<link>http://blog.tanelpoder.com/2009/02/25/60000-bind-variables-maybe-its-time-to-use-a-temporary-table-instead/comment-page-1/#comment-1053</link>
		<dc:creator>Rick</dc:creator>
		<pubDate>Wed, 25 Feb 2009 18:40:53 +0000</pubDate>
		<guid isPermaLink="false">http://blog.tanelpoder.com/?p=229#comment-1053</guid>
		<description>I suspect they were generating the query dynamically based on the number of values in the inlist.  This would also result a large number of different queries, many parses and problems with the shared pool.

I&#039;d probably use a temporary table</description>
		<content:encoded><![CDATA[<p>I suspect they were generating the query dynamically based on the number of values in the inlist.  This would also result a large number of different queries, many parses and problems with the shared pool.</p>
<p>I&#8217;d probably use a temporary table</p>
]]></content:encoded>
	</item>
</channel>
</rss>
