问题描述
嗨,汤姆
物联网的二级索引有物理猜测。然而,在插入多次后,猜测可能会变得陈旧。
这是获得新鲜猜测的两种方法:
1. Alter index...重新定义和
2. ALTER INDEX...更新块引用。
3.什么更好或更快?为什么?
如果索引的所有猜测都是新鲜的,为什么查询计划是索引唯一扫描索引范围扫描IX_ONAME,而不是索引ROWID的表访问?
4.在哪里可以看到Oracle在IOT中读取了quess,而不是主键?
谢谢
物联网的二级索引有物理猜测。然而,在插入多次后,猜测可能会变得陈旧。
这是获得新鲜猜测的两种方法:
1. Alter index...重新定义和
2. ALTER INDEX...更新块引用。
3.什么更好或更快?为什么?
如果索引的所有猜测都是新鲜的,为什么查询计划是索引唯一扫描索引范围扫描IX_ONAME,而不是索引ROWID的表访问?
4.在哪里可以看到Oracle在IOT中读取了quess,而不是主键?
谢谢
专家解答
使用更新块引用,数据库只是扫描索引以修复陈旧的猜测。而重建本质上是在重建它。
这样做的一个副作用是重建可能会使索引变小。但是更新引用对大小没有影响:
鉴于重建会重新创建索引,毫不奇怪,它会做更多的工作,如以下测试所示:
测试在12.2.0.1上运行。
运行1使用更新块引用,并且速度更快,使用更少的锁存器,并且在许多统计信息上的工作更少 (尤其是排序和物理写入,它们都是零)。
因此,如果您要做的只是修复陈旧的猜测,更新块引用看起来像是要走的路。
If all guesses of index is fresh, why query plan is INDEX UNIQUE SCAN INDEX RANGE SCAN IX_ONAME, but not TABLE ACCESS BY INDEX ROWID?
因为没有表可以访问!有了物联网,表is指数。所以 “按索引ROWID进行表访问” 是一种无效的访问方法。
Where can I see Oracle have read the quess in IOT, not primary key?
不知道你说的是什么意思。你能澄清一下吗?
如果您想了解更多信息,建议阅读Richard Foote的文章:
https://richardfoote.wordpress.com/2012/04/26/iot-secondary-indexes-the-logical-rowid-guess-component-part-i-lucky/
https://richardfoote.wordpress.com/2012/05/08/iot-secondary-indexes-the-logical-rowid-guess-component-part-ii-move-on/
这样做的一个副作用是重建可能会使索引变小。但是更新引用对大小没有影响:
create table t ( x int, y int, z int, constraint pk primary key (x, y) ) organization index; create index i on t (z); exec dbms_random.seed(0); insert into t select x.r, y.r, dbms_random.value(1, 200) from (select level r from dual connect by level <= 10000) x, (select level r from dual connect by level <= 5) y; commit; exec dbms_stats.gather_table_stats(user, 't'); select blevel, leaf_blocks from user_indexes where index_name = 'I'; BLEVEL LEAF_BLOCKS 1 236 alter index i update block references; exec dbms_stats.gather_table_stats(user, 't'); select blevel, leaf_blocks from user_indexes where index_name = 'I'; BLEVEL LEAF_BLOCKS 1 236 truncate table t; exec dbms_random.seed(0); insert into t select x.r, y.r, dbms_random.value(1, 200) from (select level r from dual connect by level <= 10000) x, (select level r from dual connect by level <= 5) y; commit; exec dbms_stats.gather_table_stats(user, 't'); select blevel, leaf_blocks from user_indexes where index_name = 'I'; BLEVEL LEAF_BLOCKS 1 236 alter index i rebuild; exec dbms_stats.gather_table_stats(user, 't'); select blevel, leaf_blocks from user_indexes where index_name = 'I'; BLEVEL LEAF_BLOCKS 1 157复制
鉴于重建会重新创建索引,毫不奇怪,它会做更多的工作,如以下测试所示:
truncate table t; exec dbms_random.seed(0); insert into t select x.r, y.r, dbms_random.value(1, 200) from (select level r from dual connect by level <= 10000) x, (select level r from dual connect by level <= 5) y; commit; exec runstats_pkg.rs_start; alter index i update block references; exec runstats_pkg.rs_pause; exec dbms_random.seed(0); truncate table t; insert into t select x.r, y.r, dbms_random.value(1, 200) from (select level r from dual connect by level <= 10000) x, (select level r from dual connect by level <= 5) y; commit; exec runstats_pkg.rs_resume; alter index i rebuild; exec runstats_pkg.rs_stop(1000, false); =============================================================================================== RunStats report : 01-NOV-2017 04:53:24 =============================================================================================== ----------------------------------------------------------------------------------------------- 1. Summary timings ----------------------------------------------------------------------------------------------- Type Name Run1 Run2 Diff ----- -------------------------------------------------- ------------ ------------ ------------ TIMER cpu time (hsecs) 20 26 6 TIMER elapsed time (hsecs) 68 91 23 Comments: 1) Run1 was 25.3% quicker than Run2 2) Run1 used 25.3% less CPU time than Run2 ----------------------------------------------------------------------------------------------- 2. Statistics report ----------------------------------------------------------------------------------------------- Type Name Run1 Run2 Diff ----- -------------------------------------------------- ------------ ------------ ------------ LATCH KTU in-memory txn table latch 1,186 116 -1,070 STAT txn cache local writes 1,185 115 -1,070 LATCH object queue header operation 86 1,243 1,157 STAT db block changes 2,154 550 -1,604 LATCH simulator hash latch 22 2,805 2,783 STAT redo size for direct writes 0 3,060 3,060 STAT KTFB alloc time (ms) 0 3,273 3,273 LATCH cache buffers chains 106,462 116,875 10,413 STAT file io wait time 235 41,699 41,464 STAT no buffer to keep pinned count 0 50,000 50,000 STAT sorts (rows) 0 50,000 50,000 STAT session uga memory 0 51,824 51,824 STAT undo change vector size 79,628 8,116 -71,512 STAT redo size 260,532 62,632 -197,900 STAT physical read bytes 245,760 819,200 573,440 STAT physical read total bytes 245,760 819,200 573,440 STAT logical read bytes from cache 417,611,776 416,915,456 -696,320 STAT physical write bytes 0 1,286,144 1,286,144 STAT physical write total bytes 0 1,286,144 1,286,144 STAT cell physical IO interconnect bytes 245,760 2,105,344 1,859,584 STAT KTFB alloc space (block) 0 2,097,152 2,097,152 STAT session pga memory -3,932,160 131,072 4,063,232 ----------------------------------------------------------------------------------------------- 3. Latching report ----------------------------------------------------------------------------------------------- Type Name Run1 Run2 Diff ----- -------------------------------------------------- ------------ ------------ ------------ LATCH total latches used 112,421 125,178 12,757 Comments: 1) Run1 used 10.2% fewer latches than Run2 ----------------------------------------------------------------------------------------------- 4. About ----------------------------------------------------------------------------------------------- - RunStats v2.01 by Adrian Billington (http://www.oracle-developer.net) - Based on the original RUNSTATS utility by Tom Kyte =============================================================================================== End of report ===============================================================================================复制
测试在12.2.0.1上运行。
运行1使用更新块引用,并且速度更快,使用更少的锁存器,并且在许多统计信息上的工作更少 (尤其是排序和物理写入,它们都是零)。
因此,如果您要做的只是修复陈旧的猜测,更新块引用看起来像是要走的路。
If all guesses of index is fresh, why query plan is INDEX UNIQUE SCAN INDEX RANGE SCAN IX_ONAME, but not TABLE ACCESS BY INDEX ROWID?
因为没有表可以访问!有了物联网,表is指数。所以 “按索引ROWID进行表访问” 是一种无效的访问方法。
Where can I see Oracle have read the quess in IOT, not primary key?
不知道你说的是什么意思。你能澄清一下吗?
如果您想了解更多信息,建议阅读Richard Foote的文章:
https://richardfoote.wordpress.com/2012/04/26/iot-secondary-indexes-the-logical-rowid-guess-component-part-i-lucky/
https://richardfoote.wordpress.com/2012/05/08/iot-secondary-indexes-the-logical-rowid-guess-component-part-ii-move-on/
「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。
评论
相关阅读
Oracle DataGuard高可用性解决方案详解
孙莹
573次阅读
2025-03-26 23:27:33
Oracle RAC 一键安装翻车?手把手教你如何排错!
Lucifer三思而后行
532次阅读
2025-04-15 17:24:06
【纯干货】Oracle 19C RU 19.27 发布,如何快速升级和安装?
Lucifer三思而后行
435次阅读
2025-04-18 14:18:38
XTTS跨版本迁移升级方案(11g to 19c RAC for Linux)
zwtian
430次阅读
2025-04-08 09:12:48
【ORACLE】记录一些ORACLE的merge into语句的BUG
DarkAthena
427次阅读
2025-04-22 00:20:37
墨天轮个人数说知识点合集
JiekeXu
427次阅读
2025-04-01 15:56:03
Oracle SQL 执行计划分析与优化指南
Digital Observer
425次阅读
2025-04-01 11:08:44
【ORACLE】你以为的真的是你以为的么?--ORA-38104: Columns referenced in the ON Clause cannot be updated
DarkAthena
404次阅读
2025-04-22 00:13:51
Oracle数据库一键巡检并生成HTML结果,免费脚本速来下载!
陈举超
391次阅读
2025-04-20 10:07:02
Oracle 19c RAC更换IP实战,运维必看!
szrsu
365次阅读
2025-04-08 23:57:08