<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>OS与Oracle &#187; 数据库性能调优</title>
	<atom:link href="http://www.os2ora.com/category/performance-tuning/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.os2ora.com</link>
	<description>专注于现实世界Oracle数据库的高性能，高可扩展性与新一代数据库Exadata架构</description>
	<lastBuildDate>Fri, 16 Jul 2010 02:55:51 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>cardinality feedback</title>
		<link>http://www.os2ora.com/cardinality-feedback/</link>
		<comments>http://www.os2ora.com/cardinality-feedback/#comments</comments>
		<pubDate>Fri, 16 Jul 2010 02:55:51 +0000</pubDate>
		<dc:creator>Kaya</dc:creator>
				<category><![CDATA[数据库性能调优]]></category>
		<category><![CDATA[11G]]></category>
		<category><![CDATA[cardinality feedback]]></category>
		<category><![CDATA[Tunning]]></category>

		<guid isPermaLink="false">http://www.os2ora.com/cardinality-feedback/</guid>
		<description><![CDATA[到了10g的时代，cardinality feedback这个词正在变得越来越流行。我想，开始导致这个词流行的或许不是来自Oracle官方的推广，而是来自Wolfgang Breitling在Hotsos Symposium 2006上的一个演讲。
到了11g，Oracle有个new feature就叫做cardinality feedback...]]></description>
			<content:encoded><![CDATA[<p><span class="Apple-style-span" style="word-spacing: 0px; font: medium simsun; text-transform: none; color: rgb(0,0,0); text-indent: 0px; white-space: normal; letter-spacing: normal; border-collapse: separate; orphans: 2; widows: 2; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px"><span class="Apple-style-span" style="font-size: 12px; color: rgb(85,85,85); font-family: verdana, &#39;BitStream vera Sans&#39;, helvetica, sans-serif; text-align: left">Kaya 发表于<span class="Apple-converted-space">&#160;</span><a style="font-weight: bold; color: rgb(102,102,102); text-decoration: underline" href="http://www.os2ora.com/">os2ora.com</a></span></span></p>
<p><span class="Apple-style-span" style="word-spacing: 0px; font: medium simsun; text-transform: none; color: rgb(0,0,0); text-indent: 0px; white-space: normal; letter-spacing: normal; border-collapse: separate; orphans: 2; widows: 2; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px"><span class="Apple-style-span" style="font-size: 12px; color: rgb(85,85,85); font-family: verdana, &#39;BitStream vera Sans&#39;, helvetica, sans-serif; text-align: left">到了10g的时代，cardinality feedback这个词正在变得越来越流行。我想，开始导致这个词流行的或许不是来自Oracle官方的推广，而是来自Wolfgang Breitling在<a href="https://portal.hotsos.com/events/SYM06">Hotsos Symposium 2006</a>上的一个演讲: </span></span>Tuning by Cardinality Feedback: Method and Examples. 从作者的网站有下面的信息:</p>
<blockquote><p><b>Tuning by Cardinality Feedback</b></p>
<p>Tuning by cardinality feedback looks at discrepancies between estimated and real row source cardinalities of an execution plan and attempts to find ways to correct the CBO’s error in estimation and trusting it to find a better plan based on the corrected, more accurate estimates.</p>
<p>Faced with an underperforming SQL, the question the TCF method is trying to answer is not      <br />&#160;&#160;&#160; What would be a better access plan?       <br />But instead       <br />&#160;&#160;&#160; Why is this plan, which the CBO chose as optimal, performing so poorly?</p>
<p>Once the answer to that question is found, the next goal is to find a way to remedy the cause for the miscalculation, but ultimately get out of the way and let the CBO do its job again.</p>
<p>The presentation was given at the 2006 Hotsos Symposium on Oracle® System Performance March 5–9, 2006 in Dallas, Texas and at CBO Days June 21-22 in Zurich, Switzerland.</p>
<p><a href="http://www.centrexcc.com/Tuning%20by%20Cardinality%20Feedback.pdf">Paper</a>&#160; <a href="http://www.centrexcc.com/Tuning%20by%20Cardinality%20Feedback.ppt.pdf">Presentation</a></p>
</blockquote>
<p>这种方法，也是我们平常调优SQL的最主要方法。虽然以前没有专门介绍过，不过有一些文章还是偶尔提及的，例如这篇: <a href="http://www.os2ora.com/fantastic-11gr2-sql-monitor-report/">11gR2出色的SQL Monitor Report</a>, 提到了用SQL Monitor Report查看actual rows与estimate rows的方法。</p>
<p>网上的另一个介绍cardinality feedback的演讲可以参考这一篇，<a href="http://jonathanlewis.wordpress.com/2009/05/11/cardinality-feedback/">http://jonathanlewis.wordpress.com/2009/05/11/cardinality-feedback/</a>,作者是<span class="Apple-style-span" style="word-spacing: 0px; font: medium simsun; text-transform: none; color: rgb(0,0,0); text-indent: 0px; white-space: normal; letter-spacing: normal; border-collapse: separate; orphans: 2; widows: 2; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px"><span class="Apple-style-span" style="font-size: 13px; line-height: 21px; font-family: verdana, tahoma, arial, sans-serif"><strong><em>Michelle Deng，</em></strong><strong><em>Sanofi Aventis.</em></strong><font color="#555555" size="2">注意这里已经是2009年的事情了。</font></span></span></p>
<p>看看Oracle内部开发人员的演讲吧，这是VLDB 2008上的一个演讲.</p>
<p>Allison W. Lee, Mohamed Zaït: Closing the query processing loop in Oracle 11g: <a href="http://www.vldb.org/pvldb/1/1454178.pdf">Paper</a>, <a href="https://www.se.auckland.ac.nz/conferences/VLDB2008resources/presentations/papers/I14.ppt">Presentation</a></p>
<p>这俨然成为了11g的一个new feature，如何你手头有Oracle 11g，你甚至现在就可以演练一下。</p>
<p>下面是一个用到了cardinality feedback的执行计划，注意最后一行: cardinality feedback used for this statement</p>
<p>&#160;</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">---------------------------------------------------------------------------------------------------------------</span>
<span style="color: #66cc66;">|</span> Id  <span style="color: #66cc66;">|</span> Operation                      <span style="color: #66cc66;">|</span> Name                         <span style="color: #66cc66;">|</span> Rows  <span style="color: #66cc66;">|</span> Bytes <span style="color: #66cc66;">|</span> Cost <span style="color: #66cc66;">&#40;</span>%CPU<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">|</span> Time     <span style="color: #66cc66;">|</span>
<span style="color: #808080; font-style: italic;">---------------------------------------------------------------------------------------------------------------</span>
<span style="color: #66cc66;">|</span>   <span style="color: #cc66cc;">0</span> <span style="color: #66cc66;">|</span> <span style="color: #993333; font-weight: bold;">SELECT</span> STATEMENT               <span style="color: #66cc66;">|</span>                              <span style="color: #66cc66;">|</span>       <span style="color: #66cc66;">|</span>       <span style="color: #66cc66;">|</span> <span style="color: #cc66cc;">98089</span> <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">100</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">|</span>          <span style="color: #66cc66;">|</span>
<span style="color: #66cc66;">|</span>   <span style="color: #cc66cc;">1</span> <span style="color: #66cc66;">|</span>  SORT <span style="color: #993333; font-weight: bold;">ORDER</span> <span style="color: #993333; font-weight: bold;">BY</span>                 <span style="color: #66cc66;">|</span>                              <span style="color: #66cc66;">|</span>     <span style="color: #cc66cc;">1</span> <span style="color: #66cc66;">|</span>    <span style="color: #cc66cc;">97</span> <span style="color: #66cc66;">|</span> <span style="color: #cc66cc;">98089</span>   <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">|</span> 00:<span style="color: #cc66cc;">19</span>:<span style="color: #cc66cc;">38</span> <span style="color: #66cc66;">|</span>
<span style="color: #66cc66;">|*</span>  <span style="color: #cc66cc;">2</span> <span style="color: #66cc66;">|</span>   HASH <span style="color: #993333; font-weight: bold;">JOIN</span>                    <span style="color: #66cc66;">|</span>                              <span style="color: #66cc66;">|</span>     <span style="color: #cc66cc;">1</span> <span style="color: #66cc66;">|</span>    <span style="color: #cc66cc;">97</span> <span style="color: #66cc66;">|</span> <span style="color: #cc66cc;">98088</span>   <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">|</span> 00:<span style="color: #cc66cc;">19</span>:<span style="color: #cc66cc;">38</span> <span style="color: #66cc66;">|</span>
<span style="color: #66cc66;">|</span>   <span style="color: #cc66cc;">3</span> <span style="color: #66cc66;">|</span>    <span style="color: #993333; font-weight: bold;">VIEW</span>                        <span style="color: #66cc66;">|</span> VW_NSO_1                     <span style="color: #66cc66;">|</span>     <span style="color: #cc66cc;">4</span> <span style="color: #66cc66;">|</span>    <span style="color: #cc66cc;">36</span> <span style="color: #66cc66;">|</span> <span style="color: #cc66cc;">47108</span>   <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">|</span> 00:09:<span style="color: #cc66cc;">26</span> <span style="color: #66cc66;">|</span>
<span style="color: #66cc66;">|</span>   <span style="color: #cc66cc;">4</span> <span style="color: #66cc66;">|</span>     SORT <span style="color: #993333; font-weight: bold;">UNIQUE</span>                <span style="color: #66cc66;">|</span>                              <span style="color: #66cc66;">|</span>     <span style="color: #cc66cc;">4</span> <span style="color: #66cc66;">|</span>   <span style="color: #cc66cc;">148</span> <span style="color: #66cc66;">|</span> <span style="color: #cc66cc;">47108</span>  <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">51</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">|</span> 00:09:<span style="color: #cc66cc;">26</span> <span style="color: #66cc66;">|</span>
<span style="color: #66cc66;">|</span>   <span style="color: #cc66cc;">5</span> <span style="color: #66cc66;">|</span>      UNION<span style="color: #66cc66;">-</span><span style="color: #993333; font-weight: bold;">ALL</span>                 <span style="color: #66cc66;">|</span>                              <span style="color: #66cc66;">|</span>       <span style="color: #66cc66;">|</span>       <span style="color: #66cc66;">|</span>            <span style="color: #66cc66;">|</span>          <span style="color: #66cc66;">|</span>
<span style="color: #66cc66;">|*</span>  <span style="color: #cc66cc;">6</span> <span style="color: #66cc66;">|</span>       <span style="color: #993333; font-weight: bold;">TABLE</span> ACCESS STORAGE <span style="color: #993333; font-weight: bold;">FULL</span><span style="color: #66cc66;">|</span> TA                           <span style="color: #66cc66;">|</span>     <span style="color: #cc66cc;">2</span> <span style="color: #66cc66;">|</span>    <span style="color: #cc66cc;">62</span> <span style="color: #66cc66;">|</span> <span style="color: #cc66cc;">23549</span>   <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">|</span> 00:04:<span style="color: #cc66cc;">43</span> <span style="color: #66cc66;">|</span>
<span style="color: #66cc66;">|*</span>  <span style="color: #cc66cc;">7</span> <span style="color: #66cc66;">|</span>       <span style="color: #993333; font-weight: bold;">TABLE</span> ACCESS STORAGE <span style="color: #993333; font-weight: bold;">FULL</span><span style="color: #66cc66;">|</span> TA                           <span style="color: #66cc66;">|</span>     <span style="color: #cc66cc;">2</span> <span style="color: #66cc66;">|</span>    <span style="color: #cc66cc;">86</span> <span style="color: #66cc66;">|</span> <span style="color: #cc66cc;">23558</span>   <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">|</span> 00:04:<span style="color: #cc66cc;">43</span> <span style="color: #66cc66;">|</span>
<span style="color: #66cc66;">|*</span>  <span style="color: #cc66cc;">8</span> <span style="color: #66cc66;">|</span>    <span style="color: #993333; font-weight: bold;">TABLE</span> ACCESS STORAGE <span style="color: #993333; font-weight: bold;">FULL</span>   <span style="color: #66cc66;">|</span> TB                           <span style="color: #66cc66;">|</span>   469K<span style="color: #66cc66;">|</span>    39M<span style="color: #66cc66;">|</span> <span style="color: #cc66cc;">50978</span>   <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">|</span> 00:<span style="color: #cc66cc;">10</span>:<span style="color: #cc66cc;">12</span> <span style="color: #66cc66;">|</span>
<span style="color: #808080; font-style: italic;">---------------------------------------------------------------------------------------------------------------</span>
&nbsp;
<span style="color: #66cc66;">....</span>
&nbsp;
Note
<span style="color: #808080; font-style: italic;">-----</span>
   <span style="color: #66cc66;">-</span> cardinality feedback used <span style="color: #993333; font-weight: bold;">FOR</span> this statement</pre></div></div>

<p>可以google下”<a href="http://www.google.com/search?q=%2B%22cardinality+feedback+used+for+this+statement%22+%2Boracle">cardinality feedback</a>”。会有人其它人的演练报告。</p>
<p>想想吧，以后的DBA，回顾这段历史，想想以前的人们如何用手工的方法用cardinality feedback 进行调优，是不是会和我们现在想着过去人们如何用手工方法进行space management, memory management的场景类似？ evolving, evolving, evolving…</p>
]]></content:encoded>
			<wfw:commentRss>http://www.os2ora.com/cardinality-feedback/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Exadata V2 架构分析 (6)</title>
		<link>http://www.os2ora.com/exadata-architecture-analysis-6/</link>
		<comments>http://www.os2ora.com/exadata-architecture-analysis-6/#comments</comments>
		<pubDate>Thu, 24 Jun 2010 03:25:27 +0000</pubDate>
		<dc:creator>Kaya</dc:creator>
				<category><![CDATA[Exadata]]></category>
		<category><![CDATA[数据库性能调优]]></category>
		<category><![CDATA[系统架构]]></category>
		<category><![CDATA[Cell Flash Cache]]></category>
		<category><![CDATA[EHCC]]></category>
		<category><![CDATA[Exadata Hybrid Columnar Compression]]></category>
		<category><![CDATA[Flash Cache]]></category>
		<category><![CDATA[Partition]]></category>
		<category><![CDATA[Storage Index]]></category>

		<guid isPermaLink="false">http://www.os2ora.com/exadata-architecture-analysis-6/</guid>
		<description><![CDATA[从第一篇开始到现在，Cell Flash Cache, Exadata Hybrid Columnar Compression, Storage Index轮番上场，加上V1版本里出现的Smart Scan，Infiniband等等，多少会给人以眼花缭乱的感觉。

最根本的一点，当然在于Exadata本身是一个balanced system。

不过，这些技术做为一个整体对实际应用会带来多大的好处呢？这不是一个很好回答的问题，当然也可以用一句话回答——具体问题具体分析......]]></description>
			<content:encoded><![CDATA[<p>Kaya 发表于 <a href="http://www.os2ora.com/">os2ora.com</a></p>
<p>做下回顾与思考。</p>
<p>从第一篇开始到现在，Cell Flash Cache, Exadata Hybrid Columnar Compression, Storage Index轮番上场，加上V1版本里出现的Smart Scan，Infiniband等等，多少会给人以眼花缭乱的感觉。</p>
<p>最根本的一点，当然在于Exadata本身是一个balanced system。</p>
<p>不过，这些技术做为一个整体对实际应用会带来多大的好处呢？这不是一个很好回答的问题，当然也可以用一句话回答——具体问题具体分析。</p>
<p>思路应该是这样的，首先明了当前系统的现状</p>
<ul>
<li>如果当前系统运作得很好，简直完美的设计，分区，并行，并发控制等都无可挑剔，业务量也没超过系统极限，那么也许只有一些技术会对性能提升比较明显，如Smart Scan。举个例子，如果原来系统没存在IO上的瓶颈，Cell Flash Cache就英雄无用武之地了。</li>
<li>如果当前系统运作得很好，简直完美的设计，分区，并行，并发控制等都无可挑剔，业务量大大超过系统极限，系统出现CPU或者IO或者Network上的瓶颈了，这时或许就是考虑升级的时候了。</li>
<li>如果当前系统为小数据量所设计，如刚开始没有分区，但随着业务量的增长，系统出现CPU或者IO或者Network上的瓶颈了，这时可以有两条途径，改进原来的设计，或者考虑硬件升级了。</li>
</ul>
<p>设计上的改进包括</p>
<ul>
<li>分区</li>
<li>压缩</li>
<li>etc.</li>
</ul>
<p>硬件上的升级包括</p>
<ul>
<li>Smart Scan</li>
<li>Flash Cache</li>
<li>Storage Index</li>
<li>etc.</li>
</ul>
<p>最后，做为一个例子，可以考核一个原来的系统（没分区，没压缩，没Flash Cache，没Storage Index），分区，压缩，Flash Cache，Storage Index，分别能带来的性能上的提升，及做为一个整体带来的性能提升。</p>
<p>感性认识还是更重要的，虽然我把它放在最后面了。</p>
<p>&#160;</p>
<p><a href="http://www.os2ora.com/wp-content/uploads/2010/06/image1.png"><img title="image" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="342" alt="image" src="http://www.os2ora.com/wp-content/uploads/2010/06/image_thumb1.png" width="662" border="0" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.os2ora.com/exadata-architecture-analysis-6/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Exadata V2 架构分析 (5)</title>
		<link>http://www.os2ora.com/exadata-architecture-analysis-5/</link>
		<comments>http://www.os2ora.com/exadata-architecture-analysis-5/#comments</comments>
		<pubDate>Tue, 22 Jun 2010 13:20:53 +0000</pubDate>
		<dc:creator>Kaya</dc:creator>
				<category><![CDATA[Exadata]]></category>
		<category><![CDATA[数据库性能调优]]></category>
		<category><![CDATA[系统架构]]></category>
		<category><![CDATA[DB2]]></category>
		<category><![CDATA[MDC]]></category>
		<category><![CDATA[Multi Dimensional Clustering]]></category>
		<category><![CDATA[SI]]></category>
		<category><![CDATA[Smart Scan]]></category>
		<category><![CDATA[Storage Index]]></category>
		<category><![CDATA[Storage Indexing]]></category>

		<guid isPermaLink="false">http://www.os2ora.com/exadata-architecture-analysis-5/</guid>
		<description><![CDATA[Exadata上另一个聪明的软件设计是实现了storage index.
如果Exadata给你的印象就是有很强大的硬件，却不会利用传统的性能优化方法，比如索引，去加快查询速度的话，那么Storage Index的出现或许会改变你的这种观念。而且，storage index是完全自动化的，它甚至不需要人工的干涉就能工作得很好......]]></description>
			<content:encoded><![CDATA[<p>Kaya 发表于 <a href="http://www.os2ora.com/">os2ora.com</a></p>
<p>Exadata上另一个聪明的软件设计是实现了storage index.</p>
<p>另一篇白皮书中有对Storage Index的一个描述 <a href="http://www.oracle.com/us/solutions/datawarehousing/039572.pdf" target="_blank">A Technical Overview of the Sun Oracle Exadata Storage Server and Database Machine</a></p>
<blockquote><p class="Default" style="margin: 0cm 0cm 0pt"><font color="#000000"><font face="Arial"><b><span lang="EN-US" style="font-size: 8pt">Storage Indexing </span></b><span lang="EN-US" style="font-size: 8pt"></span></font></font></p>
</p>
</p>
</p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt"><span lang="EN-US" style="font-family: &quot;Garamond&quot;,&quot;serif&quot;; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: garamond"><font color="#000000" size="3">Storage Indexes are a very powerful capability provided in Exadata storage that helps avoid I/O operations. The Exadata Storage Server Software creates and maintains a Storage Index in Exadata memory. The Storage Index keeps track of minimum and maximum values of columns for tables stored on that cell. When a query specifies a WHERE clause, but before any I/O is done, the Exadata software examines the Storage Index to determine if rows with the specified column value exists in the cell by comparing the column value to the minimum and maximum values maintained in the Storage Index. If the column value is outside the minimum and maximum range, scan I/O for that query is avoided. Many SQL Operations will run dramatically faster because large numbers of I/O operations are automatically replaced by a few in-memory lookups. To minimize operational overhead, Storage Indexes are created and maintained transparently and automatically by the Exadata Storage Server Software.</font></span></p>
</blockquote>
<p>如果Exadata给你的印象就是有很强大的硬件，却不会利用传统的性能优化方法，比如索引，去加快查询速度的话，那么Storage Index的出现或许会改变你的这种观念。而且，storage index是完全自动化的，它甚至不需要人工的干涉就能工作得很好。</p>
<p>Smart Scan之所以冠名以Smart，是因为它在扫描数据的时候同时做过滤操作，只把必需的数据返回给数据服务器端；而Storage Index在这里却直接避免了对Disks的访问，其Smart的程度与Smart Scan相比，或许已经到了超凡脱俗的境界了。</p>
<p>如果真要找一个类比的话，DB2中有个特性或许可以与Storage Index做下对比，那就是<a href="http://www.research.ibm.com/mdc/index.html" target="_blank">Multi Dimensional Clustering</a>. 仔细阅读下MDC的介绍，两者真的有异曲同工之妙。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.os2ora.com/exadata-architecture-analysis-5/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Exadata V2 架构分析 (4)</title>
		<link>http://www.os2ora.com/exadata-architecture-analysis-4/</link>
		<comments>http://www.os2ora.com/exadata-architecture-analysis-4/#comments</comments>
		<pubDate>Tue, 22 Jun 2010 13:12:01 +0000</pubDate>
		<dc:creator>Kaya</dc:creator>
				<category><![CDATA[Exadata]]></category>
		<category><![CDATA[数据库性能调优]]></category>
		<category><![CDATA[系统架构]]></category>
		<category><![CDATA[EHCC]]></category>
		<category><![CDATA[Exadata Hybrid Columnar Compression]]></category>
		<category><![CDATA[HCC]]></category>
		<category><![CDATA[Smart Scan]]></category>
		<category><![CDATA[白皮书]]></category>

		<guid isPermaLink="false">http://www.os2ora.com/exadata-architecture-analysis-4/</guid>
		<description><![CDATA[下一个要出场的是HCC, Hybrid Columnar Compression. 目前它是Exadata上面才有的一个特性。
在Exadata V2 架构分析 (1)中，曾提到“在软件设计上，还有另一个重头戏，它更是大大的利用起了存贮节点上的CPU处理能力，同时还能减少对带宽的争用”。Exadata的很多设计，或许从根本上讲，就在于充分利用起存贮节点上的处理能力，Smart Scan和这里所要提及的HCC，就是两个典型的代表了。HCC中文翻译过来或许就叫做混合列压缩，它是在单纯的行存贮和列存贮之间取得的一个折衷......]]></description>
			<content:encoded><![CDATA[<p>Kaya 发表于 <a href="http://www.os2ora.com/">os2ora.com</a></p>
<p>下一个要出场的是HCC, Hybrid Columnar Compression. 目前它是Exadata上面才有的一个特性，所以又叫做Exadata Hybrid Columnar Compression。</p>
<p>在<a href="http://www.os2ora.com/exadata-architecture-analysis-1/" target="_blank">Exadata V2 架构分析 (1)</a>中，曾提到“<span class="Apple-style-span" style="word-spacing: 0px; font: medium simsun; text-transform: none; color: rgb(0,0,0); text-indent: 0px; white-space: normal; letter-spacing: normal; border-collapse: separate; orphans: 2; widows: 2; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px"><span class="Apple-style-span" style="font-size: 12px; color: rgb(85,85,85); font-family: verdana, &#39;BitStream vera Sans&#39;, helvetica, sans-serif; text-align: left">在软件设计上，还有另一个重头戏，它更是大大的利用起了存贮节点上的CPU处理能力，同时还能减少对带宽的争用”。Exadata的很多设计，或许从根本上讲，就在于充分利用起存贮节点上的处理能力，Smart Scan和这里所要提及的HCC，就是两个典型的代表了。HCC中文翻译过来或许就叫做混合列压缩，它是在单纯的行存贮和列存贮之间取得的一个折衷。</span></span></p>
<p><span class="Apple-style-span" style="word-spacing: 0px; font: medium simsun; text-transform: none; color: rgb(0,0,0); text-indent: 0px; white-space: normal; letter-spacing: normal; border-collapse: separate; orphans: 2; widows: 2; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px"><span class="Apple-style-span" style="font-size: 12px; color: rgb(85,85,85); font-family: verdana, &#39;BitStream vera Sans&#39;, helvetica, sans-serif; text-align: left">一个比较好的参考文档是这篇白皮书<a href="http://www.oracle.com/technology/products/bi/db/exadata/pdf/ehcc_twp.pdf" target="_blank">Exadata Hybrid Columnar Compression</a>.</span></span></p>
<p><a href="http://www.os2ora.com/wp-content/uploads/2010/06/image.png"><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="202" alt="image" src="http://www.os2ora.com/wp-content/uploads/2010/06/image_thumb.png" width="701" border="0" /></a> </p>
<p><span class="Apple-style-span" style="word-spacing: 0px; font: medium simsun; text-transform: none; color: rgb(0,0,0); text-indent: 0px; white-space: normal; letter-spacing: normal; border-collapse: separate; orphans: 2; widows: 2; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px"><span class="Apple-style-span" style="font-size: 12px; color: rgb(85,85,85); font-family: verdana, &#39;BitStream vera Sans&#39;, helvetica, sans-serif; text-align: left">上图中，典型地，4个8KB的blocks被当成一个Compression Unit。在这个CU所能存贮的rows中，每个column被分开存贮。可以想像到，每个column里的内容是很相似的，如果与row之间的内容做比较的话。于是，对每个column的内容进行压缩，会得到很好的压缩率。根据压缩算法的不同，Oracle提供了四种不同的压缩等级，详见上面提到的白皮书，这里就不详细列出了。</span></span></p>
<p><span class="Apple-style-span" style="word-spacing: 0px; font: medium simsun; text-transform: none; color: rgb(0,0,0); text-indent: 0px; white-space: normal; letter-spacing: normal; border-collapse: separate; orphans: 2; widows: 2; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px"><span class="Apple-style-span" style="font-size: 12px; color: rgb(85,85,85); font-family: verdana, &#39;BitStream vera Sans&#39;, helvetica, sans-serif; text-align: left">到底EHCC的压缩率可以达到多少呢？白皮书中提到两个数据，可以做为参考，对于Warehouse Compression，有10x的压缩率，对于Archive Compression，有15x的压缩率。</span></span></p>
<p><span class="Apple-style-span" style="word-spacing: 0px; font: medium simsun; text-transform: none; color: rgb(0,0,0); text-indent: 0px; white-space: normal; letter-spacing: normal; border-collapse: separate; orphans: 2; widows: 2; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px"><span class="Apple-style-span" style="font-size: 12px; color: rgb(85,85,85); font-family: verdana, &#39;BitStream vera Sans&#39;, helvetica, sans-serif; text-align: left"></span></span></p>
<p><span class="Apple-style-span" style="word-spacing: 0px; font: medium simsun; text-transform: none; color: rgb(0,0,0); text-indent: 0px; white-space: normal; letter-spacing: normal; border-collapse: separate; orphans: 2; widows: 2; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px"><span class="Apple-style-span" style="font-size: 12px; color: rgb(85,85,85); font-family: verdana, &#39;BitStream vera Sans&#39;, helvetica, sans-serif; text-align: left">EHCC相对于单纯的Column Compression而言，有一个极其突出的优点，这点是不得不提及的。当进行行级访问数据时，如根据rowid返回一行数据，EHCC只要一个IO就够了，不管所访问的表有多少列，而对于单纯的Column Compression而言，对于每个Column，都必须有一个IO操作。那么，随着表设计的复杂，如一个表拥有成百上千列，两种存贮方式的性能就能体现出成百上千倍的差距了。</span></span></p>
]]></content:encoded>
			<wfw:commentRss>http://www.os2ora.com/exadata-architecture-analysis-4/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>无奈的DBA</title>
		<link>http://www.os2ora.com/helpless-dba/</link>
		<comments>http://www.os2ora.com/helpless-dba/#comments</comments>
		<pubDate>Sun, 30 May 2010 15:28:13 +0000</pubDate>
		<dc:creator>Kaya</dc:creator>
				<category><![CDATA[Exadata]]></category>
		<category><![CDATA[数据库性能调优]]></category>
		<category><![CDATA[系统架构]]></category>
		<category><![CDATA[DBA]]></category>
		<category><![CDATA[DSS]]></category>
		<category><![CDATA[Index]]></category>
		<category><![CDATA[容量规划]]></category>
		<category><![CDATA[架构]]></category>

		<guid isPermaLink="false">http://www.os2ora.com/helpless-dba/</guid>
		<description><![CDATA[在检查客户的代码中，有时会深刻地感觉到原代码编写者在调试代码时的无奈。
这使我想起以前调试代码时的经历。一个SQL迟迟不返回结果，一小时过去了，又一小时过去了...... 于是，想了好多调优的方法，调整系统参数，为这个SQL建立很多Index，加上各种各样的Hint ...... 
于是，现在在代码中看到似曾相识的/*+ index(t_xx, idx_xx) */时，有时会发自内心的笑了，同时，轻巧地把里面的+号删掉了，我就让这些个hint不起作用，不强迫CBO走index了，结果当然是CBO选择了Hash Join，而不是原代码编写者指定的Nested Loop，于是，执行速度嗖一下上去了。
有另一个有趣的事情......]]></description>
			<content:encoded><![CDATA[<p>Kaya 发表于 <a href="http://www.os2ora.com/">os2ora.com</a></p>
<p>在检查客户的代码中，有时会深刻地感觉到原代码编写者在调试代码时的无奈。</p>
<p>这使我想起以前调试代码时的经历。一个SQL迟迟不返回结果，一小时过去了，又一小时过去了&#8230;&#8230; 于是，想了好多调优的方法，调整系统参数，为这个SQL建立很多Index，加上各种各样的Hint &#8230;&#8230; </p>
<p>于是，现在在代码中看到似曾相识的/*+ index(t_xx, idx_xx) */时，有时会发自内心的笑了，同时，轻巧地把里面的+号删掉了，我就让这些个hint不起作用，不强迫CBO走index了，结果当然是CBO选择了Hash Join，而不是原代码编写者指定的Nested Loop，于是，执行速度嗖一下上去了。</p>
<p>还有另一个有趣的事情，对大表的操作DSS查询或DML操作，检查客户的执行计划，无一例外地没有用并行查询或者并行DML，当然，里面会用到很多类似上面的/*+ index(t_xx, idx_xx) */。于是，心里很纳闷，这样跑DSS查询或DML操作，要跑到啥时候才跑完啊？有趣的地方在于，发现了原代码编写者的一个可能的workaround，对大表进行分割分片处理，一次跑不完，我跑它个几百上千次还可以吧。很聪明的做法，不过也感觉到一阵阵深深的无奈。</p>
<p>不可否以地，很多客户有很复杂的业务逻辑要处理，DBA们和开发者们也很聪明地运用着Oracle的技术。编写的代码质量其实也是可圈可点的。不过，在代码实现与现实世界之间，我们却不得不面对一个折衷，优雅的代码，在糟糕的机器配置之前，只能无能为力，于是，过度的调优也就理所当然，顺理成章的成为了主流。</p>
<p>或许，我们的DBA们要主动地进行呐喊；或许，我们还需要有这样的职位，能够从大局上对系统进行规划，包括对系统硬件的容量规划，系统软件实现上的总体设计，最佳实践上的运用等等；或许，也应该是架构师工作的一部分？</p>
]]></content:encoded>
			<wfw:commentRss>http://www.os2ora.com/helpless-dba/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>测试: 一个SQL Monitor Report的具体例子</title>
		<link>http://www.os2ora.com/test-sql-monitor-report-example/</link>
		<comments>http://www.os2ora.com/test-sql-monitor-report-example/#comments</comments>
		<pubDate>Sun, 23 May 2010 14:06:17 +0000</pubDate>
		<dc:creator>Kaya</dc:creator>
				<category><![CDATA[Exadata]]></category>
		<category><![CDATA[数据库性能调优]]></category>
		<category><![CDATA[AWR]]></category>
		<category><![CDATA[PGA]]></category>
		<category><![CDATA[SQL Monitor Report]]></category>
		<category><![CDATA[Temp tablespace]]></category>
		<category><![CDATA[测试]]></category>

		<guid isPermaLink="false">http://www.os2ora.com/test-sql-monitor-report-example/</guid>
		<description><![CDATA[之前曾提到如何利用SQL Monitor Report对SQL进行诊断与调优，对于具体的SQL调优而言，SQL Monitor Report提供的信息无疑比AWR更有针对性，当然，AWR在信息的全面性方面会更胜一筹。本文提供一个具体的例子，同样的SQL，同样的执行计划，第一次执行的时间远远大于第二次执行的时间......]]></description>
			<content:encoded><![CDATA[<p>Kaya 发表于 <a href="http://www.os2ora.com/">os2ora.com</a></p>
<p>之前曾提到如何<a href="http://www.os2ora.com/use-sql-monitor-report-to-tune-and-diagnose-sql/">利用SQL Monitor Report对SQL进行诊断与调优</a>，对于具体的SQL调优而言，SQL Monitor Report提供的信息无疑比AWR更有针对性，当然，AWR在信息的全面性方面会更胜一筹。本文提供一个具体的例子，同样的SQL，同样的执行计划，第一次执行的时间远远大于第二次执行的时间。</p>
<p>SQL Monitor Report详细提供了SQL执行所消耗的系统资源曲线，每一步骤的显著等待事件。通过对比上面两种情形下的系统资源曲线，执行计划中提供的等待事件分布，基本上应该可以诊断出第二次执行为什么比第一次执行快的原因。</p>
<p>下面是两个Reports的链接，你不妨试着对比对比。也借此体验下11.2 中的SQL Monitor Report在展现信息方面的灵活性(让鼠标指向每一个可能隐藏信息的地方，如每个可能的bar)。</p>
<ul>
<li><a href="http://www.os2ora.com/wp-content/uploads/2010/05/before.html" target="_blank">第一次执行的SQL Monitor Report</a></li>
<li><a href="http://www.os2ora.com/wp-content/uploads/2010/05/after.html" target="_blank">第二次执行的SQL Monitor Report</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.os2ora.com/test-sql-monitor-report-example/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Exadata V2 架构分析 (3)</title>
		<link>http://www.os2ora.com/exadata-architecture-analysis-3/</link>
		<comments>http://www.os2ora.com/exadata-architecture-analysis-3/#comments</comments>
		<pubDate>Thu, 20 May 2010 12:14:37 +0000</pubDate>
		<dc:creator>Kaya</dc:creator>
				<category><![CDATA[Exadata]]></category>
		<category><![CDATA[数据库性能调优]]></category>
		<category><![CDATA[系统架构]]></category>
		<category><![CDATA[Cell Flash Cache]]></category>
		<category><![CDATA[Flash Cache]]></category>
		<category><![CDATA[IOPS]]></category>
		<category><![CDATA[MBPS]]></category>
		<category><![CDATA[混合负载]]></category>

		<guid isPermaLink="false">http://www.os2ora.com/exadata-architecture-analysis-3/</guid>
		<description><![CDATA[关于Cell Flash Cache，或许大家都余兴未尽，例如：
1. 一个真正的生产系统，真的需要1,000,000 IOPS吗？
2. Cell Flash Cache对用户带来的真正的好处在哪里？
假设用户的逻辑IOPS达到1,000,000 IO/s. buffer cache命中率为98%。则落在Cell Flash Cache中的IOPS为20,000次......]]></description>
			<content:encoded><![CDATA[<p>Kaya 发表于 <a href="http://www.os2ora.com/">os2ora.com</a></p>
<p>关于Cell Flash Cache，好象大家都余兴未尽，例如：    <br />1. 一个真正的生产系统，真的需要1,000,000 IOPS吗？     <br />2. Cell Flash Cache对用户带来的真正的好处在哪里？</p>
<p>假设用户的<strong><em>逻辑IOPS</em></strong>达到1,000,000 IO/s. buffer cache命中率为98%。则落在Cell Flash Cache中的IOPS为20,000次。这个数据对于1/4配，即一个quarter的Exadata来说，当然是小菜一碟，不过对于一般磁盘呢？一般的磁盘每秒大约为300 IOPS，这意味着需要有20,000/300=66个磁盘，这已经是一个不低的配置了。</p>
<p>再进一步考虑，如果系统想支持混合负载，即系统同时支持数据仓库查询和OLTP在线系统。那么这时OLTP的性能将会受到严重影响。要知道，数据仓库查询要求的MBPS，而OLTP要求的则是IOPS，这两个指标是会相互影响的，用户一般考虑的是OLTP优先。甚至于出现一种情形，我不清楚下面这种情况会多普遍：</p>
<blockquote><p>在IO受限的情形下，不敢对OLAP查询启用并行，由于不启用并行，OLAP查询很久不返回结果，进一步地，用户会在表上建更多的索引来“优化”这些OLAP查询。最终，整个混合型的系统就变成了一个类似OLTP的系统了。</p>
</blockquote>
<p>在这种情形下，Cell Flash Cache或许会带有性能上的实质提升，通过Flash Cache会大大提升OLTP的查询性能，同时，后端的磁盘和Flash Cache会<em><strong>一起</strong></em>提供足够的带宽给OLAP查询(很聪明吧)，这在硬件上保证了两者并存的可能性。另一方面，由于在IO上的财大气粗，对原有OLAP的过度优化终于可以停止了，系统设计因些会回归简单，与此对应地，系统维护成本也会大大降低。</p>
<p>或许这是Cell Flash Cache可能给大家带来的一个很诱人的地方。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.os2ora.com/exadata-architecture-analysis-3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Exadata V2 架构分析 (2)</title>
		<link>http://www.os2ora.com/exadata-architecture-analysis-2/</link>
		<comments>http://www.os2ora.com/exadata-architecture-analysis-2/#comments</comments>
		<pubDate>Sun, 16 May 2010 16:30:39 +0000</pubDate>
		<dc:creator>Kaya</dc:creator>
				<category><![CDATA[Exadata]]></category>
		<category><![CDATA[数据库性能调优]]></category>
		<category><![CDATA[系统架构]]></category>
		<category><![CDATA[buffer cache]]></category>
		<category><![CDATA[Buffer Hit Ratio]]></category>
		<category><![CDATA[Flash Cache]]></category>
		<category><![CDATA[IOPS]]></category>
		<category><![CDATA[MBPS]]></category>
		<category><![CDATA[OLTP]]></category>
		<category><![CDATA[Smart Scan]]></category>

		<guid isPermaLink="false">http://www.os2ora.com/exadata-architecture-analysis-2/</guid>
		<description><![CDATA[既然提到了Flash Cache,如果不提下对OLTP的提速好象会缺少点什么。对OLTP系统而言，缓存是一个极其重要的设计，不管是数据库节点上的内存上的Buffer Cache，还是存贮节点上的Flash Cache（Exadata)，还有数据库节点上的Flash Cache(某些平台，如Linux)......]]></description>
			<content:encoded><![CDATA[<p>Kaya 发表于 <a href="http://www.os2ora.com/">os2ora.com</a></p>
<p>既然提到了Flash Cache,如果不提下对OLTP的提速好象会缺少点什么。对OLTP系统而言，缓存是一个极其重要的设计，不管是数据库节点上的内存上的Buffer Cache，还是存贮节点上的Flash Cache（Exadata)，还有数据库节点上的Flash Cache(某些平台，如Linux)。</p>
<p>前几天在<a href="http://www.eygle.com" target="_blank">Eygle</a>的性能调优课程上听过他提过的一句话，缓存为王（致敬，呵呵），深以为然，这应该是他极其重要的实践总结，对于OLTP系统而言，这真是一点不为过。</p>
<p>下面的表格列出了一个实际场景，分别测试了不同的buffer 命中率和引入Flash Cache之后的性能变化。</p>
<table cellspacing="0" cellpadding="2" width="987" border="1">
<tbody>
<tr>
<td valign="top" width="59">Cache</td>
<td valign="top" width="89">Executions</td>
<td valign="top" width="86">Buffer Hit %</td>
<td valign="top" width="90">CPU Time (s)</td>
<td valign="top" width="100">user IO time (s)</td>
<td valign="top" width="108">Elapsed Time</td>
<td valign="top" width="134">total Elapsed Time (s)</td>
<td valign="top" width="62">CPU %</td>
<td valign="top" width="106">response time</td>
<td valign="top" width="151">SpeedUp Factor</td>
</tr>
<tr>
<td valign="top" width="67">Buffer Cache</td>
<td valign="top" width="96">30000</td>
<td valign="top" width="85">85</td>
<td valign="top" width="89">70</td>
<td valign="top" width="99">4082</td>
<td valign="top" width="106">00:02:20</td>
<td valign="top" width="133">4138</td>
<td valign="top" width="64">3</td>
<td valign="top" width="106">0.138</td>
<td valign="top" width="149">1</td>
</tr>
<tr>
<td valign="top" width="70">Flash Cache</td>
<td valign="top" width="100">30000</td>
<td valign="top" width="85">85</td>
<td valign="top" width="89">69</td>
<td valign="top" width="98">265</td>
<td valign="top" width="105">00:00:12</td>
<td valign="top" width="132">323</td>
<td valign="top" width="65">36</td>
<td valign="top" width="106">0.011</td>
<td valign="top" width="149">13</td>
</tr>
<tr>
<td valign="top" width="71">Buffer Cache</td>
<td valign="top" width="101">30000</td>
<td valign="top" width="85">100</td>
<td valign="top" width="89">19</td>
<td valign="top" width="100">0</td>
<td valign="top" width="111">00:00:02</td>
<td valign="top" width="142">26</td>
<td valign="top" width="69">61</td>
<td valign="top" width="111">0.001</td>
<td valign="top" width="165">158</td>
</tr>
</tbody>
</table>
<p>上面的三行对应的OLTP负载是相同的，但总的执行时间却是大大不同的，从2分多钟到10几秒到2秒。唯一的区别就在于Cell Flash Cache, Buffer Cache 的介入。</p>
<p>上面这些数据起码可以得出几个结论：</p>
<p>1. Buffer Cache会减少CPU Time,但Cell Flash Cache不会。这从另一个方面说明，IO调度是需要CPU的。</p>
<p>2. Cell Flash Cache和Buffer Cache都大大减少了User IO Time。最终的结果就是大大提升了响应时间，例如上面我们得到了从13倍到158倍的性能提升。</p>
<p>3. Cell Flash Cache和Buffer Cache都提高了DB节点的CPU利用率。例如上面我们的CPU利用率从3%提高到36%和61%。</p>
<p>Exadata V2宣传的一个令人惊诧的数字之一是每秒钟一百万个8K的随机IO。很恐怖吧，1,000,000 IO/s.</p>
<p>其实，如果只是进行读操作而没有写操作的话，这个数字会更令人恐怖。下面是一个截图。把里面的峰值(300k)除以3乘以14，就得到整个机器14个cell可以达到的一个IOPS: 1.4 million IO/s.</p>
<p><a href="http://www.os2ora.com/wp-content/uploads/2010/05/iops.jpg"><img title="iops" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="233" alt="iops" src="http://www.os2ora.com/wp-content/uploads/2010/05/iops_thumb.jpg" width="804" border="0" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.os2ora.com/exadata-architecture-analysis-2/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>史上最快，最具可扩展性的文本导入方法 &#8211;大数据量加载最佳实践</title>
		<link>http://www.os2ora.com/the-fastest-data-load-method-best-practice/</link>
		<comments>http://www.os2ora.com/the-fastest-data-load-method-best-practice/#comments</comments>
		<pubDate>Sat, 01 May 2010 16:06:22 +0000</pubDate>
		<dc:creator>Kaya</dc:creator>
				<category><![CDATA[Exadata]]></category>
		<category><![CDATA[数据库性能调优]]></category>
		<category><![CDATA[data pump]]></category>
		<category><![CDATA[external table]]></category>
		<category><![CDATA[load]]></category>
		<category><![CDATA[parallel]]></category>
		<category><![CDATA[RAC]]></category>
		<category><![CDATA[sqlldr]]></category>

		<guid isPermaLink="false">http://www.os2ora.com/the-fastest-data-load-method-best-practice/</guid>
		<description><![CDATA[竟然写了史上最快，最具可扩展性的文本导出方法, 模仿上一篇的语调，再写个史上最快，最具可扩展性的文本导入方法应该也是挺有趣的一件事情，试试吧，这或许能意想不到地从另一个角度阐述大数据量文本导入的特点，与大数据量文本导出的共性，与大数据量文本导出的不同，Oracle并行技术的运用。
不过，从另一方面讲，大数据量加载应该是一个比较成熟的技术，厚道一点，还是再用一个副标题吧：大数据量加载最佳实践。OK，开始模仿作文......]]></description>
			<content:encoded><![CDATA[<p>Kaya 发表于 <a href="http://www.os2ora.com/">os2ora.com</a></p>
<p>竟然写了<a href="http://www.os2ora.com/the-fastest-data-unload-method/">史上最快，最具可扩展性的文本导出方法</a>, 模仿上一篇的语调，再写个<strong>史上最快，最具可扩展性的文本导入方法</strong>应该也是挺有趣的一件事情，试试吧，这或许能意想不到地从另一个角度阐述大数据量文本导入的特点，与大数据量文本导出的共性，与大数据量文本导出的不同，Oracle并行技术的运用。</p>
<p>不过，从另一方面讲，大数据量加载应该是一个比较成熟的技术，厚道一点，还是再用一个副标题吧：大数据量加载最佳实践。OK，开始模仿作文：</p>
<p>这个题目有点吓人，不过既然这么说，当然有其强有力的后台做支撑。如果说一句谎言必须用更多的谎言来圆的话，一句真话恐怕也要用更多的真话来阐述，呵呵，且让我慢慢道来。</p>
<p>Oracle上的技术，其实是相当开放的，这里提到的这种文本导入方法，其实在官方文档中已经做了很好的论述和说明。只不过本着独乐乐不如众乐乐的想法，在这里再推广一把罢了。</p>
<p>首先明确一点，文本导入到数据库中，或者把数据从数据库中导出为文本格式，这都是极其消耗CPU的操作。所以，对于一个配置均衡的系统而言，导出速度首先取决于系统CPU的运算能力。基于大数据量处理的系统一般都是多节点的RAC系统，于是，文本导入的一个主要议题就是：如何利用起所有RAC节点的所有CPU的运算能力。</p>
<p>Oracle的Data Pump其实就达到了这个目标，在RAC系统中运行Data Pump，通过设置parallel参数，导入作业会在所有RAC节点运行，从而利用起系统可能存在的空闲的CPU资源。不过，Data Pump没有提供导入文本文件的方法。</p>
<p>如果自己实现这种并行机制呢？那也未尝不可，SQL*Loader是Oracle的一个导入文本文件工具，叫做<a href="http://download.oracle.com/docs/cd/E11882_01/server.112/e10701/ldr_concepts.htm">sqlldr</a>，这是一个单进程的工具，不过我们可以在系统中启动多个sqlldr实例，通过指定不同的实例加载不同的文本文件，从而实现并行加载。这里有几点说明一下：</p>
<ul>
<li>通过把一个表的数据分割成多个文件，可以实现对一个表的并行加载 </li>
<li>通过在RAC的多个节点上启动多个sqlldr，可以实现跨节点的并行加载 </li>
<li>必须加上parallel=true参数，在每个sqlldr 的参数文件中。 </li>
</ul>
<p>这个方法显而易见的有两个缺点</p>
<ul>
<li>必须用户自己协调多个sqlldr的运行 </li>
<li>如果只有一个数据文件，无法利用多个sqlldr实现并行加载 </li>
</ul>
<p>如果能利用起Oracle本身的并行机制，那应该是一件高效并且简单的实现。只要想想Oracle投入了多少人力开发设计并行这个技术，想想并行技术在Oracle版本中的悠久历史，我们会毫不怀疑地相信并行技术的高效性，可扩展性与稳定性。</p>
<p>并行技术的首要设计目标就是把所有可能空闲的系统资源利用起来。例如对于下面一个简单的查询</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">SELECT</span> <span style="color: #66cc66;">*</span><span style="color: #993333; font-weight: bold;">FROM</span> big_table</pre></div></div>

<p>如果现在的系统有8个节点，每个节点有8个CPU，那么这时Oracle会启动8*8*parallel_threads_per_cpu =128个并行进程。每个进程负责扫描表big_table的1/128了。与串行执行相比，扫描时间理论上会缩小为1/128，“理论上”背后主要的潜台词就是系统没有IO瓶颈了。</p>
<p>设想一下，如果这128个进程在扫描表的同时，把这些数据同时写到目标表中，这不就是我们所想要的并行文本导入功能吗？关键是找到一个途径，告诉这些并行进程在扫描的时候去扫描文本文件，而不是一个实实在在的内部表。</p>
<p>这个途径，Oracle中以External Table的形式提供。这是把文本文件映射成Table的一种技术。利用这种技术，我们可以实现把对文本文件的读取操作，转换为对数据表的select操作。</p>
<p>上面提到的就是利用Oracle本身的并行机制实现并行多节点导入数据的主要思路。至于具体的实现，可以直接参考官方文档<a href="http://download.oracle.com/et_params.htm#i1012274">The ORACLE_LOADER Access Driver</a>，这一章详细解释了外部表的定义与使用。具体的例子可以参考<a href="http://download.oracle.com/#CIHCHGCE">Example: Creating and Loading an External Table Using ORACLE_LOADER</a>。</p>
<p>我们再深入一步，到目前为止，我们应该能够穷尽整个RAC系统所有节点的CPU处理能力，仅仅是“应该”而已。想像一种情况，如果导入文件系统的IO性能很差，不能足够快地提供上面提到的128个并行进程的读取操作，那么瓶颈就会出现在磁盘IO上了。按照我们的经验，128个进程甚至可以提供接近4GB/s的加载速度。要找到一个文件服务器提供这么高的带宽对于很多数据中心而言还是不现实的。</p>
<p>解决方法在于减少对磁盘的IO量，一个马上想到的方法就是对并行进程读出的数据进行压缩。11g中，外部表定义引入了一个新的特性，叫做PREPROCESSOR，它可以实现对外部文件的预先处理，再把处理后得到的数据传送给Oracle内部进行加载。利用这个特性，我们可以实现对压缩文本文件的加载。具体而言，下面是官方文档中提到的一个例子：</p>
<p>Example 14-1 Specifying the PREPROCESSOR Clause</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;">SQL&amp;gt; <span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">TABLE</span> xtab <span style="color: #66cc66;">&#40;</span>recno varchar2<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">2000</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
     <span style="color: #cc66cc;">2</span>    ORGANIZATION EXTERNAL <span style="color: #66cc66;">&#40;</span>
     <span style="color: #cc66cc;">3</span>    TYPE ORACLE_LOADER
     <span style="color: #cc66cc;">4</span>    <span style="color: #993333; font-weight: bold;">DEFAULT</span> DIRECTORY data_dir
     <span style="color: #cc66cc;">5</span>    ACCESS PARAMETERS <span style="color: #66cc66;">&#40;</span>
     <span style="color: #cc66cc;">6</span>    RECORDS DELIMITED <span style="color: #993333; font-weight: bold;">BY</span> NEWLINE
     <span style="color: #cc66cc;">7</span>    PREPROCESSOR execdir:<span style="color: #ff0000;">'zcat'</span>
     <span style="color: #cc66cc;">8</span>    <span style="color: #993333; font-weight: bold;">FIELDS</span> <span style="color: #66cc66;">&#40;</span>recno char<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">2000</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
     <span style="color: #cc66cc;">9</span>    LOCATION <span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'foo.dat.gz'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
   <span style="color: #cc66cc;">10</span>    REJECT <span style="color: #993333; font-weight: bold;">LIMIT</span> UNLIMITED;
<span style="color: #993333; font-weight: bold;">TABLE</span> created<span style="color: #66cc66;">.</span></pre></div></div>

<p>假设gzip的压缩率为1:10，于是我们实现了把4GB/s的读取速度下降到400MB/s，另一方面，由于解压缩需要消耗一定的CPU，我们实现了用CPU换取IO的曲线救国。</p>
<p>&#160;</p>
<p>可以看出，文本导入与文本导出其实存在着很多共性。实现高性能导入/导出的原则是一样的：</p>
<ul>
<li>充分利用起系统中的CPU与IO资源，直至其中一方成为瓶颈 </li>
<li>利用压缩技术消除可能存在的IO瓶颈 </li>
</ul>
<p>另一方面，关于并行技术，它不仅包括大家喜闻乐见的并行Query，并行DML；并行import，并行export其实也是并行技术用于数据仓库场合的重要方面。并行import和并行export，我想会在企业中的ODS系统中发挥重要作用。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.os2ora.com/the-fastest-data-load-method-best-practice/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>史上最快，最具可扩展性的文本导出方法</title>
		<link>http://www.os2ora.com/the-fastest-data-unload-method/</link>
		<comments>http://www.os2ora.com/the-fastest-data-unload-method/#comments</comments>
		<pubDate>Wed, 21 Apr 2010 08:59:59 +0000</pubDate>
		<dc:creator>Kaya</dc:creator>
				<category><![CDATA[Exadata]]></category>
		<category><![CDATA[Linux性能调优]]></category>
		<category><![CDATA[数据库性能调优]]></category>
		<category><![CDATA[degree]]></category>
		<category><![CDATA[parallel]]></category>
		<category><![CDATA[pipelined table function]]></category>
		<category><![CDATA[RAC]]></category>
		<category><![CDATA[unload]]></category>

		<guid isPermaLink="false">http://www.os2ora.com/the-fastest-data-unload-method/</guid>
		<description><![CDATA[这个题目有点吓人，不过既然这么说，当然有其强有力的后台做支撑。如果说一句谎言必须用更多的谎言来圆的话，一句真话恐怕也要用更多的真话来阐述，呵呵，且让我慢慢道来。

Oracle上的技术，其实是相当开放的，这里提到的这种文本导出方法，其实在网上已经有人做了很好的论述和实现。只不过本着独乐乐不如众乐乐的想法，在这里再推广一把罢了。

首先明确一点，文本导入到数据库中，或者把数据从数据库中导出为文本格式，这都是极其消耗CPU的操作。所以，导出速度首先取决于系统CPU的运算能力。基于大数据量处理的系统一般都是多节点的RAC系统，于是，文本导出的一个主要议题就是：如何利用起所有RAC节点的所有CPU的运算能力......]]></description>
			<content:encoded><![CDATA[<p>Kaya 发表于 <a href="http://www.os2ora.com/">os2ora.com</a></p>
<p>这个题目有点吓人，不过既然这么说，当然有其强有力的后台做支撑。如果说一句谎言必须用更多的谎言来圆的话，一句真话恐怕也要用更多的真话来阐述，呵呵，且让我慢慢道来。</p>
<p>Oracle上的技术，其实是相当开放的，这里提到的这种文本导出方法，其实在网上已经有人做了很好的论述和实现。只不过本着独乐乐不如众乐乐的想法，在这里再推广一把罢了。</p>
<p>首先明确一点，文本导入到数据库中，或者把数据从数据库中导出为文本格式，这都是极其消耗CPU的操作。所以，导出速度首先取决于系统CPU的运算能力。基于大数据量处理的系统一般都是多节点的RAC系统，于是，文本导出的一个主要议题就是：如何利用起所有RAC节点的所有CPU的运算能力。</p>
<p>Oracle的Data Pump其实就达到了这个目标，在RAC系统中运行Data Pump，通过设置parallel参数，导出作业会在所有RAC节点运行，从而利用起系统可能存在的空闲的CPU资源。不过，Data Pump没有提供导出为文本格式的方法。</p>
<p>如果自己实现这种并行机制呢？那也未尝不可，目前anysql.net上有个类似的工具，叫做<a href="http://www.anysql.net/tools/parallel-inside-sqluldr2.html">sqluldr2</a>，应该就是朝着这个方向在发展。目前作者实现了对海量大表进行自动切片的算法，我想可能下一步的动作应该是在所有的RAC节点上启动多个sqluldr2实例进行导出，衷心希望这个工具能达到更好的性能。</p>
<p>如果能利用起Oracle本身的并行机制，那应该是一件高效并且简单的实现。只要想想Oracle投入了多少人力开发设计并行这个技术，想想并行技术在Oracle版本中的悠久历史，我们会毫不怀疑地相信并行技术的高效性，可扩展性与稳定性。</p>
<p>并行技术的首要设计目标就是把所有可能空闲的系统资源利用起来。例如对于下面一个简单的查询</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">SELECT</span> <span style="color: #66cc66;">*</span><span style="color: #993333; font-weight: bold;">FROM</span> big_table</pre></div></div>

<p>如果现在的系统有8个节点，每个节点有8个CPU，那么这时Oracle会启动8*8*parallel_threads_per_cpu =128个并行进程。每个进程负责扫描表big_table的1/128了。与串行执行相比，扫描时间理论上会缩小为1/128，“理论上”背后主要的潜台词就是系统没有IO瓶颈了。</p>
<p>设想一下，如果这128个进程在扫描表的同时，把这些数据同时写到文本文件中，这不就是我们所想要的并行文本导出功能吗？关键是找到一个途径，告诉这些并行进程在扫描的同时执行写出数据到文本中这个操作。</p>
<p>这个途径，Oracle中以pipelined table function的形式提供。这是一个PL/SQL函数，我们只要在这个函数里面把每个并行进程接收到的数据通过UTL_FILE.PUT函数写到文本中就达到了我们的目标了。</p>
<p>上面提到的是利用Oracle本身的并行机制实现并行多节点导出数据的主要思路。至于具体的实现，可以直接参考<a href="http://www.oracle-developer.net">www.oracle-developer.net</a>上的文章：<a href="http://www.oracle-developer.net/display.php?id=429">improving performance with pipelined table functions</a>，这篇文章详细解释了pipelined table functions在数据导入和转换（ETL），数据导出方面的杰出贡献，具体地说，数据导出部分的子标题是asynchronous data unloading with parallel pipelined functions。同时，文章提到的脚本应该是能直接下载和运行的。</p>
<p>我们再深入一步，到目前为止，我们应该能够穷尽整个RAC系统所有节点的CPU处理能力，仅仅是“应该”而已。想像一种情况，如果导出文件系统的IO性能很差，不能足够快地消化上面提到的128个并行进程的写入操作，那么瓶颈就会出现在磁盘IO上了。按照我们的经验，128个进程提供接近1GB每秒的写出量还是有可能了。要找到一个文件服务器提供这么高的带宽对于很多数据中心而言还是不现实的。</p>
<p>解决方法在于减少对磁盘的IO量，一个马上想到的方法就是对并行进程写出的数据进行压缩。然后再把压缩后的数据写往磁盘。在Unix系统中，这可能通过文件管道的形式实现：并行进程把数据写入管道文件中，gzip进程通过读取管道文件，对数据进行压缩，然后再把它写入到目标磁盘中。</p>
<p>假设gzip的压缩率为1:10，于是我们实现了把1GB/s的写入下降到100MB/s，这是一个大部分文件服务器能达到的指标了。同时，我们在导出的同时做了后面我们很可能做的事情，压缩数据以便于减少数据空间或者以利于网络传输。</p>
<p>不知道上面的论述能否对得起这篇文章的标题 <img src='http://www.os2ora.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.os2ora.com/the-fastest-data-unload-method/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
