扫一扫
分享文章到微信
扫一扫
关注官方公众号
至顶头条
SQL> select sql_text 2 from v$sqltext a 3 where a.hash_value = ( 4 select sql_hash_value from v$session b 5 where b.sid='&sid' 6 ) 7 order by piece asc 8 / SQL_TEXT ---------------------------------------------------------------- select * from i_cm_power t WHERE T.SJH='13911xxxxx6' |
SQL> select index_name from dba_indexes where table_name=upper('i_cm_power'); INDEX_NAME ------------------------------ |
SQL> col segment_name for a20 SQL> select segment_name,bytes/1024/1024/1024 from dba_segments where segment_name=upper('i_cm_power'); SEGMENT_NAME BYTES/1024/1024/1024 -------------------- -------------------- I_CM_POWER 5.28173828125 |
SQL> create index idx_i_cm_power_sjh on i_cm_power(sjh); Index created. Elapsed: 00:20:50.73 SQL> col segment_name for a20 SQL> select segment_name,bytes/1024/1024 MB 2 from dba_segments where segment_name=upper('idx_i_cm_power_sjh'); SEGMENT_NAME MB -------------------- ---------- IDX_I_CM_POWER_SJH 1360 SQL> |
SQL> select * from i_cm_power t WHERE T.SJH='13911xxxxx6'; Elapsed: 00:00:00.07 Execution Plan ---------------------------------------------------------- 0 SELECT STATEMENT Optimizer=CHOOSE 1 0 TABLE ACCESS (BY INDEX ROWID) OF 'I_CM_POWER' 2 1 INDEX (RANGE SCAN) OF 'IDX_I_CM_POWER_SJH' (NON-UNIQUE) Statistics ---------------------------------------------------------- 0 recursive calls 0 db block gets 6 consistent gets 0 physical reads 0 redo size 1022 bytes sent via SQL*Net to client 503 bytes received via SQL*Net from client 2 SQL*Net roundtrips to/from client 0 sorts (memory) 0 sorts (disk) 2 rows processed |
然而在实际中,你需要考虑更多的因素。
增加索引会占用更多的存储空间;索引的维护会增加数据库的负担,如果有海量的数据加载,可能会极大影响性能...
所以事实可能总是比你想象的更复杂,你只有知道的更多...
如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。
现场直击|2021世界人工智能大会
直击5G创新地带,就在2021MWC上海
5G已至 转型当时——服务提供商如何把握转型的绝佳时机
寻找自己的Flag
华为开发者大会2020(Cloud)- 科技行者