当前位置:网站首页>Oracle create index
Oracle create index
2022-07-26 10:38:00 【Zhao Yong】
create table scott.idx_object_id on scott.test(object_id);
Now you need to scott.test Of object_id Create an index on the column , For example, there are 50GB
How can I check this process halfway , It should be Mr. Cheng as a temporary section , What about the size of this temporary segment ?
Other answers 1:
If you are concerned about the progress of index creation , You can query v$session_longops View .
Other answers 2:
Hello! , I am not concerned about this progress , It's the size change of that temporary segment
Other answers 3:
You can try this , Just tested , Not bad .
select k.inst_id "INST_ID",
ktssoses "SADDR",
sid,
ktssosno "SERIAL#",
username "USERNAME",
osuser "OSUSER",
ktssosqlid "SQL_ID",
ktssotsn "TABLESPACE",
decode(ktssocnt, 0, 'PERMANENT', 1, 'TEMPORARY') "CONTENTS",
-- Pay attention to 12c Of v$sort_usage In the definition TABLESPACE and CONTENTS It has changed .
decode(ktssosegt, 1, 'SORT', 2, 'HASH', 3, 'DATA', 4, 'INDEX',
5, 'LOB_DATA', 6, 'LOB_INDEX' , 'UNDEFINED') "SEGTYPE",
ktssofno "SEGFILE#",
ktssobno "SEGBLK#",
ktssoexts "EXTENTS",
ktssoblks "BLOCKS",
round(ktssoblks*p.value/1024/1024, 2) "SIZE_MB",
ktssorfno "SEGRFNO#"
from x$ktsso k, v$session s,
(select value from v$parameter where name='db_block_size') p
where ktssoses = s.saddr
and ktssosno = s.serial#;
Other answers 4:
Thank you two , Today's test has found a way , At the time of creation dba_segments.segment_type Would be TEMPORARY, Until the index is created , according to dba_segments Just count
Other answers 5:
When the index creation action is executed , You can query the following sql To monitor the progress of index creation :
select L.sid ssid, l.SERIAL#, l.START_TIME, substr(OPNAME, 1, 15) opname, target, trunc((sofar / totalwork) * 100) pct, to_char(60 * sofar * 8192 / (24 * 60 * (last_update_time - start_time)) / 1024 / 1024 / 60, '9999.0') Rate, elapsed_seconds / 60 es, time_remaining / 60 tr, PROGRAM, MACHINE from gv$session_longops L, gV$SESSION S where time_remaining > 0 AND L.SID = S.SID;
Index creation takes precedence by default PGA, When ALLOC GB exceed PGA Big hour , Will be used for temporary tablespaces , And the speed will be relatively slow , Therefore, it is necessary to monitor the use of temporary tables :
-- Temporary table space sort segment usage select tablespace_name,current_users,total_blocks,used_blocks,free_blocks,added_extents,extent_hits,freed_extents,free_requests,max_blocks,max_used_blocks,max_sort_blocks from gv$sort_segment;-- Session information of temporary table space select username,session_num,sql_id,tablespace,contents,segtype,segfile#,segblk#,extents,blocks from gv$tempseg_usage;-- Temporary table space usage select df.tablespace_name "Tablespace", df.totalspace "Total(MB)", nvl(FS.UsedSpace, 0) "Used(MB)", (df.totalspace - nvl(FS.UsedSpace, 0)) "Free(MB)", round(100 * (1-( nvl(fs.UsedSpace, 0) / df.totalspace)), 2) "Pct. Free(%)"FROM (SELECT tablespace_name, round(SUM(bytes) / 1048576) TotalSpace FROM dba_TEMP_files GROUP BY tablespace_name) df, (SELECT tablespace_name, ROUND(SUM(bytes_used) / 1024 / 1024) UsedSpace FROM gV$temp_extent_pool GROUP BY tablespace_name) fs WHERE df.tablespace_name = fs.tablespace_name(+);
Of course, it can also be used in advance dbms_space.create_index_cost To evaluate the size of the index :, But the accuracy depends on whether the statistical information is accurate , For reference only :
set serveroutput onDECLARE used_bytes NUMBER; alloc_bytes NUMBER;BEGIN dbms_space.create_index_cost(' Create an index statement ', used_bytes, alloc_bytes); dbms_output.put_line('index used gb: ' || round(used_bytes/1024/1024/1024,2) || 'G; ' || 'index alloc gb: ' || round(alloc_bytes/1024/1024/1024,2) || 'G;');END;/
I hope I can help you ~
Other answers 6:
well , Thank you thank you , Collected
边栏推荐
猜你喜欢

hx711 数据波动大的问题
![[leetcode每日一题2021/2/14]765. 情侣牵手](/img/be/8639a05c733638bf0b3fdeb11abccf.png)
[leetcode每日一题2021/2/14]765. 情侣牵手

工厂模式详解

第7期:内卷和躺平,你怎么选

vscode上使用anaconda(已经配置好环境)
![[leetcode每日一题2021/5/8]1723. 完成所有工作的最短时间](/img/e7/a48bb5b8a86cbc4cd5b37bb16661a8.png)
[leetcode每日一题2021/5/8]1723. 完成所有工作的最短时间

Oracle cannot start tnslistener service cannot start

多目标优化系列1---NSGA2的非支配排序函数的讲解

Issue 7: how do you choose between curling up and lying flat

Issue 6: which mainstream programming language should college students choose
随机推荐
.NET 开源框架在工业生产中的应用
Using native JS to realize custom scroll bar (click to reach, drag to reach)
sigmod 函数与softmax 函数对比
[leetcode每日一题2021/4/23]368. 最大整除子集
Okaleido ecological core equity Oka, all in fusion mining mode
上传图片获取宽高
[转]ArcGIS中判断两个Geometry之间的关系
Zongzi battle - guess who can win
.NET操作Redis String字符串
控制随机抽中几率 [ C# | Random ]
C语言计算日期间隔天数
2022/07/25 ------ arrangement of strings
一文详解Nodejs中fs文件模块与path路径模块
A semicolon is missing
Write to esp8266 burning brush firmware
[Halcon vision] morphological expansion
oracle 启动不了 tnslistener服务启动不了
MD5加密
10 令 operator= 返回一个 reference to *this
Tradingview 使用教程