ITPub博客

首页 > 数据库 > Oracle > 临时统计 SQL 的 “暗礁”:ORA-00600 [xtydty2ldi] 排查实录

临时统计 SQL 的 “暗礁”:ORA-00600 [xtydty2ldi] 排查实录

原创 Oracle 作者:marui 时间:2025-07-24 12:35:06 0 删除 编辑

2025 年 7 月 23 日 星期三 晴

午后的阳光透过百叶窗在桌面上投下斑驳的光影,我百无聊赖地翻着桌上的数据库手册,指尖划过索引优化的章节时,聊天软件突然 “叮” 地一声弹出提示 —— 是某客户的技术支持请求。

“我们有一条 SQL 执行时报错,能不能帮忙看看?” 消息后面跟着一张报错截图。我随手点开回复 “稍等,我看看”,很快收到了更详细的说明:这条 SQL 是临时写的,用 PLSQL Developer 执行,原本是要统计些数据用于汇报,可每次运行都会弹出 ORA-00600 错误,括号里的参数固定是 [xtydty2ldi],后面跟着一串空值。

这种内部错误向来麻烦。普通的语法错误会明确指出哪行少了逗号、哪个表名拼错了,可 ORA-00600 更像数据库的 “暗语”,得从那些神秘参数里找线索。我让客户把完整 SQL 发过来,快速浏览时注意到:多层子查询嵌套着三张表的关联,里面有聚合函数统计、字符拼接,还有时间转换和 group by 分组 —— 这些都是很常规的操作,逻辑上看不出问题。

“这是临时取数的脚本,之前没这么用过。” 客户补充道。看来不是长期运行的程序突然出故障,更像是临时脚本触发了特定场景下的异常。我把 SQL 语句复制到本地编辑器里,准备先复现问题看看具体情况。


完整SQL语句:(注:此为示例,非真实表名)

select a.*

from (select day, TNO, count(1) task_count, sum(CW) as total_ton, sum(value) as total_mile

      from (select a.TNO,

                   to_char(ING, 'yyyy-MM-dd') day,

                   b.CW,

                   c.VALUE

            from truck.A a

                     left join truck.B b on a.CUSTNO = b.CUSTNO and a.CN = b.CN

                     left join truck.C c on c.FKID = 81 and c.APP_C = a.FT || ',' || a.ST

            where a.IOT = '0'

              and a.CS = 'F'

              and IOGD >= timestamp '2025-07-01 00:00:00'

              and IOGD < timestamp '2025-07-03 00:00:00')

      group by TNO, day) a

         left join truck.B b on a.TNO = b.TNO


问题处理步骤:

1. SQL 拆分测试

尝试将一条 SQL 语句拆分成两条 SQL 语句,并借助 create table 生成临时表,两条 SQL 均可以运行。

create table temp2025 as 

select day, TNO, count(1) task_count, sum(CW) as total_ton, sum(value) as total_mile

      from (select a.TNO,

                   to_char(ING, 'yyyy-MM-dd') day,

                   b.CW,

                   c.VALUE

            from truck.A a

                     left join truck.B b on a.CUSTNO = b.CUSTNO and a.CN = b.CN

                     left join truck.C c on c.FKID = 81 and c.APP_C = a.FT || ',' || a.ST

            where a.IOT = '0'

              and a.CS = 'F'

              and IOGD >= timestamp '2025-07-01 00:00:00'

              and IOGD < timestamp '2025-07-03 00:00:00')

      group by TNO, day;


select a.*

from temp2025 a

         left join truck.B b on a.TNO = b.TNO;


2. 查找 MOS 文档

根据 ORA-600 的相关代码尝试搜索 MOS,根据 MOS 信息提示:命中 Bug 18317074 Query fails with ORA-600 [xtydty2ldi] using function based index,看标题似乎与函数索引相关,且本次故障数据库版本在受影响范围内。


3. 会话参数测试

根据 MOS 提示信息,在同一个会话中设置这个隐含参数,而后确实可以执行该SQL,结果如下:

alter session set "_disable_function_based_index"=true;

select a.*

from (select day, TNO, count(1) task_count, sum(CW) as total_ton, sum(value) as total_mile

      from (select a.TNO,

                   to_char(ING, 'yyyy-MM-dd') day,

                   b.CW,

                   c.VALUE

            from truck.A a

                     left join truck.B b on a.CUSTNO = b.CUSTNO and a.CN = b.CN

                     left join truck.C c on c.FKID = 81 and c.APP_C = a.FT || ',' || a.ST

            where a.IOT = '0'

              and a.CS = 'F'

              and IOGD >= timestamp '2025-07-01 00:00:00'

              and IOGD < timestamp '2025-07-03 00:00:00')

      group by TNO, day) a

         left join truck.B b on a.TNO = b.TNO;


4. HINT 参数设置

通过 alter session 很不方便,尝试将隐含参数配置在 hint 中,这样方便客户后续修改统计SQL,语句可以正常执行:

select /*+ OPT_PARAM('_disable_function_based_index', 'true')a.*

from (select day, TNO, count(1) task_count, sum(CW) as total_ton, sum(value) as total_mile

      from (select a.TNO,

                   to_char(ING, 'yyyy-MM-dd') day,

                   b.CW,

                   c.VALUE

            from truck.A a

                     left join truck.B b on a.CUSTNO = b.CUSTNO and a.CN = b.CN

                     left join truck.C c on c.FKID = 81 and c.APP_C = a.FT || ',' || a.ST

            where a.IOT = '0'

              and a.CS = 'F'

              and IOGD >= timestamp '2025-07-01 00:00:00'

              and IOGD < timestamp '2025-07-03 00:00:00')

      group by TNO, day) a

         left join truck.B b on a.TNO = b.TNO;


到此时问题已经可以解决,我本想对比一下原始SQL与hint SQL的执行计划,并找出相关的函数索引,但是此时客户那边似乎忙着处理其他事情,无法继续提供远程方式,只得作罢。


来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/70047128/viewspace-3091980/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论
要得到你想要的某样东西,最可靠的办法是让你自己配得上它。

注册时间:2025-07-21

  • 博文量
    30
  • 访问量
    31693