1 Star 0 Fork 0

matrix/Oracle-Database-Scripts

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
indexlargerthantable.sql 2.28 KB
一键复制 编辑 原始数据 按行查看 历史
Prashant Dixit 提交于 2021-12-09 17:49 . Create indexlargerthantable.sql
PROMPT
PROMPT
PROMPT~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
PROMPT------ /) (\
PROMPT------ .-._((,~~.))_.-,
PROMPT------ `-. @@ ,-'
PROMPT------ / ,o--o. \
PROMPT------ ( ( .__. ) )
PROMPT------ ) `----' (
PROMPT------ / \
PROMPT------ / \
PROMPT------ / \
PROMPT------ "The Silly Cow"
PROMPT----- Script: indexlargerthantable.sql
PROMPT----- Author: Prashant 'The FatDBA'
PROMPT----- Cat: Performance Management and Issue Identification
PROMPT----- Version: V1.6 (Date: 08-02-2019)
PROMPT-----
PROMPT-----
PROMPT-----
PROMPT~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~WITH
tables AS (
SELECT
owner,
segment_name,
SUM(bytes) bytes
FROM dba_segments
WHERE 'Y' = 'Y'
AND segment_type LIKE 'TABLE%'
GROUP BY
owner,
segment_name
),
indexes AS (
SELECT
owner,
segment_name,
SUM(bytes) bytes
FROM dba_segments
WHERE 'Y' = 'Y'
AND segment_type LIKE 'INDEX%'
GROUP BY
owner,
segment_name
),
idx_tbl AS (
SELECT
d.table_owner,
d.table_name,
d.owner,
d.index_name,
SUM(i.bytes) bytes
FROM indexes i,
dba_indexes d
WHERE i.owner = d.owner
AND i.segment_name = d.index_name
GROUP BY
d.table_owner,
d.table_name,
d.owner,
d.index_name
),
total AS (
SELECT
t.owner table_owner,
t.segment_name table_name,
t.bytes t_bytes,
i.owner index_owner,
i.index_name,
i.bytes i_bytes
FROM tables t,
idx_tbl i
WHERE t.owner = i.table_owner
AND t.segment_name = i.table_name
AND i.bytes > t.bytes
AND t.bytes > POWER(10,7) /* 10M */
)
SELECT table_owner,
table_name,
ROUND(t_bytes / POWER(10,9), 3) table_gb,
index_owner,
index_name,
ROUND(i_bytes / POWER(10,9), 3) index_gb,
ROUND((i_bytes - t_bytes) / POWER(10,9), 3) dif_gb,
ROUND(100 * (i_bytes - t_bytes) / t_bytes, 1) dif_perc
FROM total
ORDER BY
table_owner,
table_name,
index_owner,
index_name;
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/gregwu/Oracle-Database-Scripts.git
git@gitee.com:gregwu/Oracle-Database-Scripts.git
gregwu
Oracle-Database-Scripts
Oracle-Database-Scripts
main

搜索帮助