SonarTableSize:
Load *;
select a.table_schema schema_nm, a.table_enm table_enm
, sum(a.table_size_byte) table_size_byte
, sum(a.total_size_byte) total_size_byte
, max(b.last_upd_dtm) last_upd_dtm
from
(select table_schema, table_enm_pt, table_size, total_size, table_enm
, case
when position(' bytes' in table_size) - 1 > 0
then cast(substr(table_size, 1, position(' bytes' in table_size) - 1) as numeric)
when position(' kB' in table_size) - 1 > 0
then cast(substr(table_size, 1, position(' kB' in table_size) - 1) as numeric) * 1024
when position(' MB' in table_size) - 1 > 0
then cast(substr(table_size, 1, position(' MB' in table_size) - 1) as numeric) * 1024 * 1024
when position(' GB' in table_size) - 1 > 0
then cast(substr(table_size, 1, position(' GB' in table_size) - 1) as numeric) * 1024 * 1024 * 1024
when position(' TB' in table_size) - 1 > 0
then cast(substr(table_size, 1, position(' TB' in table_size) - 1) as numeric) * 1024 * 1024 * 1024 * 1024
end table_size_byte
, case
when position(' bytes' in total_size) - 1 > 0
then cast(substr(total_size, 1, position(' bytes' in total_size) - 1) as numeric)
when position(' kB' in total_size) - 1 > 0
then cast(substr(total_size, 1, position(' kB' in total_size) - 1) as numeric) * 1024
when position(' MB' in total_size) - 1 > 0
then cast(substr(total_size, 1, position(' MB' in total_size) - 1) as numeric) * 1024 * 1024
when position(' GB' in total_size) - 1 > 0
then cast(substr(total_size, 1, position(' GB' in total_size) - 1) as numeric) * 1024 * 1024 * 1024
when position(' TB' in total_size) - 1 > 0
then cast(substr(total_size, 1, position(' TB' in total_size) - 1) as numeric) * 1024 * 1024 * 1024 * 1024
end total_size_byte
from
(select nspname table_schema
, relname as table_enm_pt
, pg_size_pretty(pg_relation_size(c.oid)) as table_size
, pg_size_pretty(pg_total_relation_size(c.oid)) as total_size
, case
when position('_20' in relname) - 1 > 0
then substr(relname, 1, position('_20' in relname) - 1)
when position('_others' in relname) - 1 > 0
then substr(relname, 1, position('_others' in relname) - 1)
else relname
end table_enm
from pg_class c
left join pg_namespace n
on n.oid = c.relnamespace
where 1=1
--and relname like 'hddpi_cgo_wtl%'
and c.relkind <> 'i'
and nspname !~ '^pg_toast') a ) a
left join
(select schema_nm, table_enm
, max(etl_end_dtm) last_upd_dtm
from cmmdb.etl_job_log
group by schema_nm, table_enm) b
on b.schema_nm = a.table_schema
and b.table_enm = a.table_enm
where 1=1
and a.table_schema not in ('cron','hint_plan','information_schema','pg_catalog','public')
and a.table_enm not like 'v\_%'
--and table_enm = 'hddpi_cgo_wtl'
group by a.table_schema, a.table_enm
order by table_size_byte desc
;
// created by Yang
시각화 결과
'Qlik Sense 개발가이드' 카테고리의 다른 글
(클릭센스) 조건에 따른 측정값 선택 (0) | 2022.12.30 |
---|---|
피벗테이블에서 차원에 종속되는 측정값 (0) | 2022.12.25 |
콤보차트를 이용한 매출 및 영업이익 시각화 (0) | 2022.12.21 |
클릭센스 미니차트(스파크라인)에 도움말 표시 (0) | 2022.12.18 |
클릭센스의 강력한 Set Expression (0) | 2022.12.18 |