标签云
asm恢复 bbed bootstrap$ dul kcbzib_kcrsds_1 kccpb_sanity_check_2 kcratr_nab_less_than_odr MySQL恢复 obet ORA-00312 ORA-00704 ORA-00742 ORA-01110 ORA-01200 ORA-01555 ORA-01578 ORA-01595 ORA-600 2662 ORA-600 2663 ORA-600 3020 ORA-600 4000 ORA-600 4137 ORA-600 4193 ORA-600 4194 ORA-600 16703 ORA-600 kcbzib_kcrsds_1 ORA-600 KCLCHKBLK_4 ORA-600 kcratr_nab_less_than_odr ORA-15042 ORA-15196 ORACLE 12C oracle dul ORACLE PATCH Oracle Recovery Tools oracle加密恢复 oracle勒索 oracle勒索恢复 oracle异常恢复 ORACLE恢复 Oracle 恢复 ORACLE数据库恢复 oracle碎片 OSD-04016 YOUR FILES ARE ENCRYPTED 比特币加密文章分类
- MongoDB (1)
- MongoDB恢复 (1)
- Others (2)
- 中间件 (2)
- WebLogic (2)
- 操作系统 (112)
- 数据库 (1,884)
- DB2 (22)
- MySQL (82)
- Oracle (1,709)
- Data Guard (53)
- EXADATA (8)
- GoldenGate (24)
- ORA-xxxxx (168)
- ORACLE 12C (72)
- ORACLE 18C (6)
- ORACLE 19C (15)
- ORACLE 21C (3)
- Oracle 23ai (8)
- Oracle ASM (73)
- Oracle Bug (8)
- Oracle RAC (56)
- Oracle 安全 (6)
- Oracle 开发 (28)
- Oracle 监听 (29)
- Oracle备份恢复 (662)
- Oracle安装升级 (108)
- Oracle性能优化 (62)
- 专题索引 (5)
- 勒索恢复 (91)
- PostgreSQL (37)
- pdu工具 (7)
- PostgreSQL恢复 (13)
- SQL Server (34)
- SQL Server恢复 (14)
- TimesTen (7)
- 达梦数据库 (5)
- 达梦恢复 (3)
- 生活娱乐 (2)
- 至理名言 (11)
- 虚拟化 (2)
- VMware (2)
- 软件开发 (51)
- Asp.Net (9)
- JavaScript (12)
- PHP (2)
- 小工具 (34)
- MongoDB (1)
-
最近发表
- 记录19c ASM磁盘掉线触发ORA-59048故障处理
- aix平台Oracle数据库由于断电无法启动故障处理
- 断电引起ORA-600 3005故障处理
- 记录一次云存储资源到期之后引起的数据库恢复
- Firebird 损坏数据库数据抢救工具—firebirdext
- Oracle 19c 202610补丁(RUs+OJVM)-19.33
- 由于con$.con#值达到极限,触发数据库增加约束报ORA-600 12807错误
- MongoDB 离线提取工具—mongoext
- .bres勒索病毒加密数据库dmp文件可恢复
- ORA-600 krsm_mrp_rebuild_lf_list.lno_mismatch
- 记录一次0丢失的ORA-00354: 损坏重做日志块标头故障恢复
- 不当数据库恢复操作导致一个月数据丢失
- obet快速修复oracle 位图损坏块
- 不太常见的10.2.0.1的oracle redo损坏恢复
- obet forcecopy功能抢救硬件故障中的数据文件
- kcratr_nab_less_than_odr和system坏块故障处理
- 通过obet 恢复system坏块,打开数据库
- obet dbv功能完整说明
- 分享一例运行在aix上的sap系统数据库恢复过程
- OBET-Oracle Block Editor Tool使用说明
分类目录归档:数据库
DB2备份恢复(全备与恢复)
日志模式
[db2inst1@xifenfei ~]$ db2 get db cfg for xff |grep -i log Log retain for recovery status = NO User exit for logging status = YES --(1) Catalog cache size (4KB) (CATALOGCACHE_SZ) = 260 Log buffer size (4KB) (LOGBUFSZ) = 98 Log file size (4KB) (LOGFILSIZ) = 1024 Number of primary log files (LOGPRIMARY) = 6 Number of secondary log files (LOGSECOND) = 4 Changed path to log files (NEWLOGPATH) = Path to log files = /home/db2inst1/xff/redolog/NODE0000/ Overflow log path (OVERFLOWLOGPATH) = Mirror log path (MIRRORLOGPATH) = First active log file = S0000013.LOG Block log on disk full (BLK_LOG_DSK_FUL) = NO Block non logged operations (BLOCKNONLOGGED) = NO Percent max primary log space by transaction (MAX_LOG) = 0 Num. of active log files for 1 active UOW(NUM_LOG_SPAN) = 0 Percent log file reclaimed before soft chckpt (SOFTMAX) = 520 Log retain for recovery enabled (LOGRETAIN) = OFF User exit for logging enabled (USEREXIT) = OFF HADR log write synchronization mode (HADR_SYNCMODE) = NEARSYNC First log archive method (LOGARCHMETH1) = DISK:/home/db2inst1/xff/archivelog/ --(2) Options for logarchmeth1 (LOGARCHOPT1) = Second log archive method (LOGARCHMETH2) = OFF Options for logarchmeth2 (LOGARCHOPT2) = Failover log archive path (FAILARCHPATH) = Number of log archive retries on error (NUMARCHRETRY) = 5 Log archive retry Delay (secs) (ARCHRETRYDELAY) = 20 Log pages during index build (LOGINDEXBUILD) = OFF
由(1)和(2)可以判断该数据库处于归档日志模式下
查看当前存在备份
[db2inst1@xifenfei ~]$ db2 list history backup all for xff
List History File for xff
Number of matching file entries = 1
Op Obj Timestamp+Sequence Type Dev Earliest Log Current Log Backup ID
-- --- ------------------ ---- --- ------------ ------------ --------------
B D 20120406053431001 F D S0000000.LOG S0000000.LOG
----------------------------------------------------------------------------
Contains 2 tablespace(s):
00001 SYSCATSPACE
00002 USERSPACE1
----------------------------------------------------------------------------
Comment: DB2 BACKUP XFF OFFLINE --离线备份
Start Time: 20120406053431
End Time: 20120406053439
Status: A
----------------------------------------------------------------------------
EID: 1 Location: /tmp
在线全备
[db2inst1@xifenfei ~]$ db2 backup db xff online to /tmp include logs
Backup successful. The timestamp for this backup image is : 20120411165312
[db2inst1@xifenfei ~]$ db2 list history backup all for xff
List History File for xff
Number of matching file entries = 2
Op Obj Timestamp+Sequence Type Dev Earliest Log Current Log Backup ID
-- --- ------------------ ---- --- ------------ ------------ --------------
B D 20120406053431001 F D S0000000.LOG S0000000.LOG
----------------------------------------------------------------------------
Contains 2 tablespace(s):
00001 SYSCATSPACE
00002 USERSPACE1
----------------------------------------------------------------------------
Comment: DB2 BACKUP XFF OFFLINE --本次试验的online备份
Start Time: 20120406053431
End Time: 20120406053439
Status: A
----------------------------------------------------------------------------
EID: 1 Location: /tmp
Op Obj Timestamp+Sequence Type Dev Earliest Log Current Log Backup ID
-- --- ------------------ ---- --- ------------ ------------ --------------
B D 20120411165312001 N D S0000013.LOG S0000013.LOG
----------------------------------------------------------------------------
Contains 3 tablespace(s):
00001 SYSCATSPACE
00002 USERSPACE1
00003 SYSTOOLSPACE
----------------------------------------------------------------------------
Comment: DB2 BACKUP XFF ONLINE
Start Time: 20120411165312
End Time: 20120411165322
Status: A
----------------------------------------------------------------------------
EID: 19 Location: /tmp
当前数据库当前数据
[db2inst1@xifenfei ~]$ db2 connect to xff
Database Connection Information
Database server = DB2/LINUX 9.5.9
SQL authorization ID = DB2INST1
Local database alias = XFF
[db2inst1@xifenfei ~]$ db2 list tables
Table/View Schema Type Creation time
------------------------------- --------------- ----- --------------------------
T_XFF DB2INST1 T 2012-04-05-09.45.29.148434
T_XIFENFEI DB2INST1 T 2012-04-06-05.50.11.111469
2 record(s) selected.
[db2inst1@xifenfei ~]$ db2 "create table t_xifenfei01 like t_xff"
DB20000I The SQL command completed successfully.
[db2inst1@xifenfei ~]$ db2 "insert into t_xifenfei01
> select * from t_xff"
DB20000I The SQL command completed successfully.
[db2inst1@xifenfei ~]$ db2 "insert into t_xifenfei01
select * from t_xff"
DB20000I The SQL command completed successfully.
[db2inst1@xifenfei ~]$ db2 "select count(*) from t_xifenfei01"
1
-----------
734
1 record(s) selected.
恢复数据库
[db2inst1@xifenfei ~]$ db2 restore db xff from /tmp taken at 20120411165312
SQL2539W Warning! Restoring to an existing database that is the same as the
backup image database. The database files will be deleted.
Do you want to continue ? (y/n) y
DB20000I The RESTORE DATABASE command completed successfully.
[db2inst1@xifenfei ~]$ db2 "rollforward db xff to end of logs and stop"
Rollforward Status
Input database alias = xff
Number of nodes have returned status = 1
Node number = 0
Rollforward status = not pending
Next log file to be read =
Log files processed = S0000013.LOG - S0000014.LOG
Last committed transaction = 2012-04-11-08.56.20.000000 UTC
DB20000I The ROLLFORWARD command completed successfully.
[db2inst1@xifenfei ~]$ db connect to xff
-bash: db: command not found
[db2inst1@xifenfei ~]$ db2 connect to xff
Database Connection Information
Database server = DB2/LINUX 9.5.9
SQL authorization ID = DB2INST1
Local database alias = XFF
[db2inst1@xifenfei ~]$ db2 list tables
Table/View Schema Type Creation time
------------------------------- --------------- ----- --------------------------
T_XFF DB2INST1 T 2012-04-05-09.45.29.148434
T_XIFENFEI DB2INST1 T 2012-04-06-05.50.11.111469
T_XIFENFEI01 DB2INST1 T 2012-04-11-16.55.51.853649
3 record(s) selected.
[db2inst1@xifenfei ~]$ db2 "select count(*) from t_xifenfei01"
1
-----------
734
1 record(s) selected.
备份恢复是dba最重要的职责,本篇做为db2学习过程中第一篇关于备份恢复文章,后续将继续学习db2增量备份恢复等知识.
发表在 DB2
评论关闭
OER 7451 in Load Indicator : Error Code = OSD-04500:指定了非法选项
alert 日志错误
OER 7451 in Load Indicator : Error Code = OSD-04500:指定了非法选项
Sun Apr 22 11:15:51 2012 OER 7451 in Load Indicator : Error Code = OSD-04500: 指定了非法选项 O/S-Error: (OS 1) 函数不正确。 ! OER 7451 in Load Indicator : Error Code = OSD-04500: 指定了非法选项 O/S-Error: (OS 1) 函数不正确。 ! Sun Apr 22 11:16:01 2012 OER 7451 in Load Indicator : Error Code = OSD-04500: 指定了非法选项 O/S-Error: (OS 1) 函数不正确。 ! OER 7451 in Load Indicator : Error Code = OSD-04500: 指定了非法选项 O/S-Error: (OS 1) 函数不正确。 ! Sun Apr 22 11:16:11 2012 OER 7451 in Load Indicator : Error Code = OSD-04500: 指定了非法选项 O/S-Error: (OS 1) 函数不正确。 !
错误信息说明
07451, 00000, "slskstat: unable to obtain load information." // *Cause: kstat library returned an error. Possible OS failure // *Action: Check result code in sercose[0] for more information.
数据库版本信息
SQL> select * from v$version; BANNER ------------------------------------------------------------------------ Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - Production <<== 32位数据库 PL/SQL Release 11.2.0.3.0 - Production CORE 11.2.0.3.0 Production TNS for 32-bit Windows: Version 11.2.0.3.0 - Production NLSRTL Version 11.2.0.3.0 - Production
操作系统信息
C:\Users\XIFENFEI>systeminfo
主机名: XIFENFEI-PC
OS 名称: Microsoft Windows 7 旗舰版
OS 版本: 6.1.7601 Service Pack 1 Build 7601
OS 制造商: Microsoft Corporation
OS 配置: 独立工作站
OS 构件类型: Multiprocessor Free
注册的所有人: XIFENFEI
注册的组织: Microsoft
产品 ID: 00426-068-8452196-86428
初始安装日期: 2012/2/28, 20:37:08
系统启动时间: 2012/4/22, 9:16:07
系统制造商: Dell Inc.
系统型号: Inspiron N4050
系统类型: x64-based PC <<==操心系统是win 7 64位
处理器: 安装了 1 个处理器。
[01]: Intel64 Family 6 Model 42 Stepping 7 GenuineIntel ~2300 Mhz
BIOS 版本: Dell Inc. A06, 2011/11/14
Windows 目录: C:\Windows
系统目录: C:\Windows\system32
启动设备: \Device\HarddiskVolume1
系统区域设置: zh-cn;中文(中国)
输入法区域设置: zh-cn;中文(中国)
时区: (UTC+08:00)北京,重庆,香港特别行政区,乌鲁木齐
物理内存总量: 8,100 MB
可用的物理内存: 5,196 MB
虚拟内存: 最大值: 9,122 MB
虚拟内存: 可用: 5,315 MB
虚拟内存: 使用中: 3,807 MB
页面文件位置: D:\pagefile.sys
域: WORKGROUP
登录服务器: \\XIFENFEI-PC
错误原因
Installed 32-bit Oracle database software on a 64-bit MS Windows OS which is not supported.
Note: For the Database software, you can ONLY install the x64 version on MS Windows (x64).
You can NOT install the 32-bit version Database software on MS Windows (x64).
解决办法
Install 32-bit Oracle database software only on 32-bit MS Windows OS.
执行计划中常见index访问方式
近期有朋友对于单个表上的index各种情况比较模糊,这里对于单个表上,单个index出现的大多数情况进行了总结性测试,给出了测试结果,至于为什么出现这样的试验结果未做过多解释,给读者留下思考的空间.本篇文章仅仅是为了测试hint对index的影响,而不是说明走各种index方式的好坏.参考: INDEX FULL SCAN vs INDEX FAST FULL SCAN
创建表模拟测试
SQL> create table t_xifenfei as select object_id,object_name from dba_objects; Table created. SQL> create index i_t_object_id on t_xifenfei(object_id); Index created. SQL> exec dbms_stats.gather_table_stats(USER,'T_XIFENFEI',cascade=>true); PL/SQL procedure successfully completed. SQL> desc t_xifenfei Name Null? Type ----------------------------------------- -------- ---------------------------- OBJECT_ID NUMBER OBJECT_NAME VARCHAR2(128)
TABLE ACCESS FULL
SQL> SET AUTOT TRACE EXP STAT
SQL> SELECT OBJECT_ID FROM T_XIFENFEI;
49838 rows selected.
Execution Plan
----------------------------------------------------------
Plan hash value: 548923532
--------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
--------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 49838 | 243K| 57 (2)| 00:00:01 |
| 1 | TABLE ACCESS FULL| T_XIFENFEI | 49838 | 243K| 57 (2)| 00:00:01 |
--------------------------------------------------------------------------------
Statistics
----------------------------------------------------------
1 recursive calls
0 db block gets
3544 consistent gets
0 physical reads
0 redo size
721203 bytes sent via SQL*Net to client
36927 bytes received via SQL*Net from client
3324 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
49838 rows processed
SQL> SELECT /*+ INDEX(T i_t_object_id) */ OBJECT_ID FROM T_XIFENFEI;
49838 rows selected.
Execution Plan
----------------------------------------------------------
Plan hash value: 548923532
--------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
--------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 49838 | 243K| 57 (2)| 00:00:01 |
| 1 | TABLE ACCESS FULL| T_XIFENFEI | 49838 | 243K| 57 (2)| 00:00:01 |
--------------------------------------------------------------------------------
Statistics
----------------------------------------------------------
1 recursive calls
0 db block gets
3544 consistent gets
0 physical reads
0 redo size
721203 bytes sent via SQL*Net to client
36927 bytes received via SQL*Net from client
3324 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
49838 rows processed
从上面的执行计划中可知,此时走了全表扫描. 由于我们需要查询的列为object_id,因此理论上只需要读取索引就应该可以返回所有数据,而此时为什么是全表扫描呢? 这是因为NULL值与索引的特性所决定的.即null值不会被存储到B树索引.因此应该为表 t_xifenfei 的列 object_id 添加 not null 约束.
INDEX FAST FULL SCAN
SQL> alter table t_xifenfei modify(object_id not null);
Table altered.
SQL> SELECT object_id from t_xifenfei;
49838 rows selected.
Execution Plan
----------------------------------------------------------
Plan hash value: 2036340805
--------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
--------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 49838 | 243K| 27 (4)| 00:00:01 |
| 1 | INDEX FAST FULL SCAN| I_T_OBJECT_ID | 49838 | 243K| 27 (4)| 00:00:01 |
--------------------------------------------------------------------------------------
Statistics
----------------------------------------------------------
1 recursive calls
0 db block gets
3432 consistent gets
0 physical reads
0 redo size
721203 bytes sent via SQL*Net to client
36927 bytes received via SQL*Net from client
3324 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
49838 rows processed
INDEX FAST FULL SCAN:当在高速缓存中没有找到所需的索引块时,则根据db_file_multiblock_read_count的值进行多块读操作.对于索引的分支结构只是简单的获取,然后扫描所有的叶结点.其结果是导致索引结构没有访问,获取的数据没有根据索引键的顺序排序.INDEX FAST FULL SCAN使用multiblock_read,故产生db file scattered reads 事件.
INDEX RANGE SCAN
SQL> select object_id from t_xifenfei where object_id<10;
8 rows selected.
Execution Plan
----------------------------------------------------------
Plan hash value: 2197008162
----------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
----------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 2 | 10 | 2 (0)| 00:00:01 |
|* 1 | INDEX RANGE SCAN| I_T_OBJECT_ID | 2 | 10 | 2 (0)| 00:00:01 |
----------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
1 - access("OBJECT_ID"<10)
Statistics
----------------------------------------------------------
1 recursive calls
0 db block gets
3 consistent gets
0 physical reads
0 redo size
499 bytes sent via SQL*Net to client
385 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
8 rows processed
SQL> select /*+ index_ffs(t i_t_object_id) */ object_id from t_xifenfei t where object_id<10;
8 rows selected.
Execution Plan
----------------------------------------------------------
Plan hash value: 2036340805
--------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
--------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 2 | 10 | 27 (4)| 00:00:01 |
|* 1 | INDEX FAST FULL SCAN| I_T_OBJECT_ID | 2 | 10 | 27 (4)| 00:00:01 |
--------------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
1 - filter("OBJECT_ID"<10)
Statistics
----------------------------------------------------------
1 recursive calls
0 db block gets
118 consistent gets
0 physical reads
0 redo size
499 bytes sent via SQL*Net to client
385 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
8 rows processed
1
这里可以看出index_ffs已经生效,但是对于这样的情况hint index_ffs效率一般来说不会太高.
<br>
<strong>INDEX FULL SCAN</strong>
1
SQL> SELECT /*+ INDEX(T i_t_object_id) */ object_id from t_xifenfei t;
49838 rows selected.
Execution Plan
----------------------------------------------------------
Plan hash value: 431110666
----------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
----------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 49838 | 243K| 113 (2)| 00:00:02 |
| 1 | INDEX FULL SCAN | I_T_OBJECT_ID | 49838 | 243K| 113 (2)| 00:00:02 |
----------------------------------------------------------------------------------
Statistics
----------------------------------------------------------
1 recursive calls
0 db block gets
3426 consistent gets
0 physical reads
0 redo size
721203 bytes sent via SQL*Net to client
36927 bytes received via SQL*Net from client
3324 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
49838 rows processed
INDEX FULL SCAN:完全按照索引存储的顺序依次访问整个索引树.当访问到叶结点之后,按照双向链表方式读取相连节点的值.换言之,对于索引上所有的数据是按照有序的方式来读取的.如果索引块没有在高速缓存中被找到时,则需要从数据文件中单块进行读取.对于需要读取大量数据的全索引扫描而言,这将使其变得低效.INDEX FULL SCAN使用single read,故产生db file sequential reads事件.新版的Oracle支持db file parallel reads方式.
HINT INDEX不会使用INDEX FAST FULL SCAN功能.
INDEX列ORDER BY
SQL> SELECT OBJECT_ID FROM T_XIFENFEI order by object_id ;
49838 rows selected.
Execution Plan
----------------------------------------------------------
Plan hash value: 431110666
----------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
----------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 49838 | 243K| 113 (2)| 00:00:02 |
| 1 | INDEX FULL SCAN | I_T_OBJECT_ID | 49838 | 243K| 113 (2)| 00:00:02 |
----------------------------------------------------------------------------------
Statistics
----------------------------------------------------------
1 recursive calls
0 db block gets
3426 consistent gets
0 physical reads
0 redo size
721203 bytes sent via SQL*Net to client
36927 bytes received via SQL*Net from client
3324 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
49838 rows processed
SQL> SELECT OBJECT_ID FROM T_XIFENFEI order by object_id desc;
49838 rows selected.
Execution Plan
----------------------------------------------------------
Plan hash value: 2808014233
--------------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
--------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 49838 | 243K| 113 (2)| 00:00:02 |
| 1 | INDEX FULL SCAN DESCENDING| I_T_OBJECT_ID | 49838 | 243K| 113 (2)| 00:00:02 |
--------------------------------------------------------------------------------------------
Statistics
----------------------------------------------------------
1 recursive calls
0 db block gets
3427 consistent gets
0 physical reads
0 redo size
721203 bytes sent via SQL*Net to client
36927 bytes received via SQL*Net from client
3324 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
49838 rows processed
SQL> SELECT /*+ index_ffs(t i_t_object_id) */ object_id from t_xifenfei t order by object_id;
49838 rows selected.
Execution Plan
----------------------------------------------------------
Plan hash value: 2527678987
-----------------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes |TempSpc| Cost (%CPU)| Time |
-----------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 49838 | 243K| | 185 (4)| 00:00:03 |
| 1 | SORT ORDER BY | | 49838 | 243K| 1192K| 185 (4)| 00:00:03 |
| 2 | INDEX FAST FULL SCAN| I_T_OBJECT_ID | 49838 | 243K| | 27 (4)| 00:00:01 |
-----------------------------------------------------------------------------------------------
Statistics
----------------------------------------------------------
1 recursive calls
0 db block gets
117 consistent gets
0 physical reads
0 redo size
721203 bytes sent via SQL*Net to client
36927 bytes received via SQL*Net from client
3324 SQL*Net roundtrips to/from client
1 sorts (memory)
0 sorts (disk)
49838 rows processed
对于index 列排序,默认情况下会使用INDEX FULL SCAN/INDEX FULL SCAN DESCENDING而不选择使用INDEX FAST FULL SCAN,因为INDEX FAST FULL SCAN获得数据后,还需要做一次SORT ORDER BY操作
INDEX FAST FULL SCAN+SORT AGGREGATE
SQL> SELECT count(object_id) FROM T_XIFENFEI;
Execution Plan
----------------------------------------------------------
Plan hash value: 3095383276
-------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Cost (%CPU)| Time |
-------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 27 (4)| 00:00:01 |
| 1 | SORT AGGREGATE | | 1 | | |
| 2 | INDEX FAST FULL SCAN| I_T_OBJECT_ID | 49838 | 27 (4)| 00:00:01 |
-------------------------------------------------------------------------------
Statistics
----------------------------------------------------------
1 recursive calls
0 db block gets
117 consistent gets
0 physical reads
0 redo size
421 bytes sent via SQL*Net to client
385 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
1 rows processed
SQL> SELECT /*+ INDEX(T i_t_object_id) */ count(object_id) FROM T_XIFENFEI t;
Execution Plan
----------------------------------------------------------
Plan hash value: 3079973526
--------------------------------------------------------------------------
| Id | Operation | Name | Rows | Cost (%CPU)| Time |
--------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 113 (2)| 00:00:02 |
| 1 | SORT AGGREGATE | | 1 | | |
| 2 | INDEX FULL SCAN| I_T_OBJECT_ID | 49838 | 113 (2)| 00:00:02 |
--------------------------------------------------------------------------
Statistics
----------------------------------------------------------
1 recursive calls
0 db block gets
111 consistent gets
0 physical reads
0 redo size
421 bytes sent via SQL*Net to client
385 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
1 rows processed
sort aggregate通常发生在使用一些聚合函数的时候,sum(),avg(),min(),max(),count()等等,实际上sort aggregate不做真正的sort,并不会用到排序空间,而是通过一个全局变量+全表或全索引扫描来实现.这样的操作在默认情况下使用INDEX FAST FULL SCAN
INDEX FULL SCAN (MIN/MAX)
SQL> SELECT max(object_id) FROM T_XIFENFEI;
Execution Plan
----------------------------------------------------------
Plan hash value: 2939893782
--------------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
--------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 5 | 2 (0)| 00:00:01 |
| 1 | SORT AGGREGATE | | 1 | 5 | | |
| 2 | INDEX FULL SCAN (MIN/MAX)| I_T_OBJECT_ID | 49838 | 243K| 2 (0)| 00:00:01 |
--------------------------------------------------------------------------------------------
Statistics
----------------------------------------------------------
1 recursive calls
0 db block gets
2 consistent gets
0 physical reads
0 redo size
419 bytes sent via SQL*Net to client
385 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
1 rows processed
SQL> SELECT /*+ index_ffs(t i_t_object_id) */ max(object_id) FROM T_XIFENFEI t;
Execution Plan
----------------------------------------------------------
Plan hash value: 2939893782
--------------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
--------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 5 | 27 (4)| 00:00:01 |
| 1 | SORT AGGREGATE | | 1 | 5 | | |
| 2 | INDEX FULL SCAN (MIN/MAX)| I_T_OBJECT_ID | 49838 | 243K| 27 (4)| 00:00:01 |
--------------------------------------------------------------------------------------------
Statistics
----------------------------------------------------------
1 recursive calls
0 db block gets
2 consistent gets
0 physical reads
0 redo size
419 bytes sent via SQL*Net to client
385 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
1 rows processed
对于这样的查询INDEX FULL SCAN (MIN/MAX)明显是最优,但是此处奇怪的是使用了index_ffs提示无效,如果有知道的朋友,麻烦告知原因.
发表在 Oracle
评论关闭

加我微信(17813235971)
加我QQ(107644445)

