<?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>惜分飞 &#187; SYS_OP_C2C</title>
	<atom:link href="https://www.xifenfei.com/tag/sys_op_c2c/feed" rel="self" type="application/rss+xml" />
	<link>https://www.xifenfei.com</link>
	<description>提供7*24专业数据库(Oracle,SQL Server,MySQL,PostgreSQL等)恢复和技术支持@Tel:17813235971</description>
	<lastBuildDate>Sat, 07 Nov 2026 15:45:44 +0000</lastBuildDate>
	<language>zh-CN</language>
		<sy:updatePeriod>hourly</sy:updatePeriod>
		<sy:updateFrequency>1</sy:updateFrequency>
	
	<item>
		<title>重现sql执行计划SYS_OP_C2C隐式转换</title>
		<link>https://www.xifenfei.com/2021/09/sys_op_c2c.html</link>
		<comments>https://www.xifenfei.com/2021/09/sys_op_c2c.html#comments</comments>
		<pubDate>Wed, 01 Sep 2021 14:54:49 +0000</pubDate>
		<dc:creator><![CDATA[惜分飞]]></dc:creator>
				<category><![CDATA[Oracle]]></category>
		<category><![CDATA[SYS_OP_C2C]]></category>

		<guid isPermaLink="false">https://www.xifenfei.com/?p=9437</guid>
		<description><![CDATA[联系：手机/微信(+86 17813235971) QQ(107644445)  &#8230; <a href="https://www.xifenfei.com/2021/09/sys_op_c2c.html">继续阅读 <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<div id="xifenfeicopyright">
<p>联系：<a href="https://www.xifenfei.com/about_xifenfei" target="_blank">手机/微信(+86 17813235971)   QQ(107644445)</a><a target="_blank" href="http://wpa.qq.com/msgrd?v=3&#038;uin=107644445&#038;site=qq&#038;menu=yes"><img src="https://www.xifenfei.com/wp-content/themes/img/site_qq.jpg" alt="QQ咨询惜分飞" title="QQ咨询惜分飞"/></a></p>
<p>标题：<a href="https://www.xifenfei.com/2021/09/sys_op_c2c.html" target="_blank">重现sql执行计划SYS_OP_C2C隐式转换</a></p>
<p>作者：<a href="https://www.xifenfei.com" target="_blank">惜分飞</a>©版权所有[未经本人同意,不得以任何形式转载,否则有进一步追究法律责任的权利.]</p>
</div>
<p>在一次的sql优化中,遇到SYS_OP_C2C函数,通过分析是由于一个表的varchar2和另外一个表的nvarchar2列进行关联导致,通过以下简单使用进行重现.对于这个问题,如果需要使用index,需要创建SYS_OP_C2C的函数index,或者把列类型修改一致.</p>
<pre class="brush: sql; title: ; notranslate">
SQL&gt; create user xff identified by oracle;

用户已创建。

SQL&gt; grant dba to xff;

授权成功。

SQL&gt; create table xff.t1(id number,name varchar2(100));

表已创建。

SQL&gt; insert into xff.t1 select  object_id,object_name from dba_objects;

已创建 89932 行。

SQL&gt; commit;

提交完成。

SQL&gt; create table xff.t2(id number,name nvarchar2(100));

表已创建。

SQL&gt; insert into xff.t2 select  object_id,object_name from dba_objects;

已创建 89933 行。

SQL&gt; commit;

提交完成。


SQL&gt; exec dbms_stats.gather_table_stats('XFF','T1',cascade=&gt;true);

PL/SQL 过程已成功完成。

SQL&gt; exec dbms_stats.gather_table_stats('XFF','T2',cascade=&gt;true);

PL/SQL 过程已成功完成。


SQL&gt; set autot on
SQL&gt;  select count(1) from xff.t1, xff.t2 where t1.name=t2.name;

  COUNT(1)
----------
    160752


执行计划
----------------------------------------------------------
Plan hash value: 906334482

------------------------------------------------------------------------------------
| Id  | Operation           | Name | Rows  | Bytes |TempSpc| Cost (%CPU)| Time     |
------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT    |      |     1 |    74 |       |   760   (1)| 00:00:10 |
|   1 |  SORT AGGREGATE     |      |     1 |    74 |       |            |          |
|*  2 |   HASH JOIN         |      |   146K|    10M|  3256K|   760   (1)| 00:00:10 |
|   3 |    TABLE ACCESS FULL| T1   | 89932 |  2195K|       |   137   (1)| 00:00:02 |
|   4 |    TABLE ACCESS FULL| T2   | 89933 |  4303K|       |   205   (1)| 00:00:03 |
------------------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------

   2 - access(&quot;T2&quot;.&quot;NAME&quot;=SYS_OP_C2C(&quot;T1&quot;.&quot;NAME&quot;))
</pre>
<p>还有一种情况也可能发生该转换,比如使用dblink的访问远程库,本地库和远程库字符集不一致.参考:SQL Statements Performed Across Database Links run Slowly. Explain Plan Shows Function SYS_OP_C2C has been Applied to Predicates, and Query uses a Full Table Scan. (Doc ID 2010872.1)</p>
<div id="crp_related"><ul><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2012/05/sql-profile-%e4%bd%bf%e7%94%a8.html" rel="bookmark" class="crp_title">sql profile 使用</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2011/09/10g%e6%96%b0%e5%a2%9e%e5%88%97%e6%96%b9%e5%bc%8f%e6%8c%87%e5%ae%9ahint.html" rel="bookmark" class="crp_title">10g新增列方式指定HINT</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2012/12/%e5%88%9b%e5%bb%ba%e6%94%af%e6%8c%81null-index.html" rel="bookmark" class="crp_title">创建包含null值index</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2019/04/sql-plan-baseline.html" rel="bookmark" class="crp_title">sql plan baseline简单介绍</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2012/05/bind-variable-peeking-%e6%b5%8b%e8%af%95.html" rel="bookmark" class="crp_title">Bind Variable Peeking 测试</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2017/06/_optimizer_null_aware_antijoin-not-in.html" rel="bookmark" class="crp_title">_optimizer_null_aware_antijoin和not in效率</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2012/04/%e6%89%a7%e8%a1%8c%e8%ae%a1%e5%88%92%e4%b8%ad%e5%b8%b8%e8%a7%81index%e8%ae%bf%e9%97%ae%e6%96%b9%e5%bc%8f.html" rel="bookmark" class="crp_title">执行计划中常见index访问方式</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2011/09/oracle%e7%9b%b4%e6%96%b9%e5%9b%be%e7%90%86%e8%a7%a3%e4%b8%8e%e5%ae%9e%e9%aa%8c.html" rel="bookmark" class="crp_title">Oracle直方图理解与实验</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2012/06/optimizer_index_caching%e5%92%8coptimizer_index_cost_adj%e5%8f%82%e6%95%b0%e8%af%b4%e6%98%8e.html" rel="bookmark" class="crp_title">OPTIMIZER_INDEX_CACHING和OPTIMIZER_INDEX_COST_ADJ参数说明</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2014/03/%e5%90%abis-null-sql%e8%af%ad%e5%8f%a5%e4%bc%98%e5%8c%96.html" rel="bookmark" class="crp_title">含is null sql语句优化</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2024/05/ora-00600-16515.html" rel="bookmark" class="crp_title">收集统计信息报ORA-00600 16515问题解决</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2012/01/%e5%88%9b%e5%bb%ba%e5%90%absysdate%e7%9a%84%e5%87%bd%e6%95%b0index.html" rel="bookmark" class="crp_title">创建含sysdate的函数index</a></li></ul></div>]]></content:encoded>
			<wfw:commentRss>https://www.xifenfei.com/2021/09/sys_op_c2c.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
