Oracle 12c: arraysize会影响结果集么?

SQL*Plus中ArraySize的设置会影响结果集的数量么?先不要轻易说“NO”,我们来看看Jonathan Lewis最近一篇文章中披露的一个案例。

当确定的查询在arraysize改变的情况下,结果集的数量出现不同:

SQL> set transaction read only; Transaction set. SQL> set arraysize 1 SQL> select ... ... 541 rows selected. SQL> set arraysize 4 SQL> select ... ... 599 rows selected. SQL> set arraysize 10 SQL> select ... ... 620 rows selected. SQL> set arraysize 32 SQL> select ... ... 616 rows selected.

从查询结果看,随着arraysize的不同,结果集的数量忽多忽少,这显然不科学,一定是BUG导致的。

在执行计划中,可以看到12c的主要的特殊之处在于:rowset 的出现。这是Oracle 12c中引入的一个新特性。

当然,对于每一个新特性,Oracle都会提供隐含参数去控制,我们可以通过设置 _rowsets_enable=false 去关闭这一新特性。

参考链接:

https://jonathanlewis.wordpress.com/2015/11/09/wrong-results/

Oracle Support很快响应这一问题并给出进一步的WorkAround,可以通过设置Event 10055的特定级别修复该问题:

event = "10055 trace name context forever, level 2097152"

这个Bug的补丁也很快被提供出来,大家可以通过MOS找到这个BUG的修复补丁:Bug 22173980 : WRONG RESULTS WHEN "_ROWSETS_ENABLED" = TRUE 。

其影响的范围是 12.1.0.1 和 12.1.0.2 。参考:Note 2079913.1 。对于CDB环境下,还有另外一个参数 _rowsets_cdb_view_enabled 与这一特性有关,必要时需要关闭这个特性。BUG 17016479 也值得参考。

公开的BUG信息指出,这个问题出现的原因在于:当HASH JOIN在RowSet之间进行多次处理时,在特定情况下,其索引(ridx)定位行有问题,导致返回的结果集出现错误。

Internal Problem Description
----------------------------
The failing query involved several nested loops on top of a hash join.The
 hash join consumed rowsets from its two inputs and produced one row at a time for its parent.The top nested loops returned the rows to kpofcr, which returned rows=0 when the array fetch size was reached (the default was 15). After all the fetch functions returned, the release functions were called, in order to end the call.
  In the release function of the hash join, after the child release was done, it restored the last row it returned to its parent.This involved a call to qesrSetupOneCtxRow to use a row in the rowset where it saved away the input rows.If the last row it returned happened to be the first row in the rowset,and the index (ridx) was set to 0,the release was incorrectly restoring the last row in the rowset instead of the first.This led to wrong results.

Internal Fix Description
------------------------
Modified the hash join release function to use the saved row index when the yet2finishrset_qerhjm flag is set, even if it is 0. That is,if it still has rows to process in the last rowset it received from the child, then the value stored in ridx is the last row that was returned to the parent.  Only in the case that it finished processing the input rowset (and yet2finishrset_qerhjm is false) will a value of 0 for ridx indicate that the last row returned was the last row in the last input rowset.

参考Jonathan和Mos的文档可以了解这个有趣的Bug。

原文发布于微信公众号 - 数据和云(OraNews)

原文发表时间:2015-11-27

本文参与腾讯云自媒体分享计划,欢迎正在阅读的你也加入,一起分享。

发表于

我来说两句

0 条评论
登录 后参与评论

相关文章

来自专栏一个爱瞎折腾的程序猿

sqlserver使用存储过程跟踪SQL

USE [master] GO /****** Object: StoredProcedure [dbo].[sp_perfworkload_trace_s...

2000
来自专栏张善友的专栏

Silverlight + Model-View-ViewModel (MVVM)

     早在2005年,John Gossman写了一篇关于Model-View-ViewModel模式的博文,这种模式被他所在的微软的项目组用来创建Expr...

2898
来自专栏张善友的专栏

LINQ via C# 系列文章

LINQ via C# Recently I am giving a series of talk on LINQ. the name “LINQ via C...

2615
来自专栏陈仁松博客

ASP.NET Core 'Microsoft.Win32.Registry' 错误修复

今天在发布Asp.net Core应用到Azure的时候出现错误InvalidOperationException: Cannot find compilati...

4798
来自专栏Golang语言社区

【Golang语言社区】GO1.9 map并发安全测试

var m sync.Map //全局 func maintest() { // 第一个 YongHuomap := make(map[st...

4668
来自专栏java 成神之路

使用 NIO 实现 echo 服务器

4517
来自专栏杨龙飞前端

scrollto 到指定位置

2494
来自专栏一个会写诗的程序员的博客

Spring Reactor 项目核心库Reactor Core

Non-Blocking Reactive Streams Foundation for the JVM both implementing a Reactiv...

2112
来自专栏C#

DotNet加密方式解析--非对称加密

    新年新气象,也希望新年可以挣大钱。不管今年年底会不会跟去年一样,满怀抱负却又壮志未酬。(不过没事,我已为各位卜上一卦,卦象显示各位都能挣钱...)...

4798
来自专栏魂祭心

原 canvas绘制clock

4024

扫码关注云+社区