如何计算Teradata数据库中的可用空间

时间:2013-08-16 16:01:29

标签: teradata

我想报告特定Teradata数据库的各种统计数据,特别是“自由空间”。表格偏差是否应包含在计算中?例如,有人建议以下查询:

SELECT databasename
     , SUM(maxperm)/1024/1024/1024 (DECIMAL(10,2))     AS space_allocated
     , SUM(currentperm)/1024/1024/1024 (DECIMAL(10,2)) AS space_Used
     , (MAX(currentperm)*COUNT(*)-SUM(currentperm))
        /1024/1024/1024 (DECIMAL(10, 2)) AS skew_Size

     , (space_used + skew_size) AS total_space_used

     , (MIN(maxperm-currentperm)/1024/1024/1024) * COUNT(*) (DECIMAL(10,2)) 
        AS free_Space

     ,  CAST(total_space_used AS DECIMAL(10,2)) * 100 
      / CAST(space_allocated AS DECIMAL(10,2)) AS pct_used

FROM   DBC.diskspace
WHERE  databasename = 'MyDatabase'
   AND maxperm > 0
GROUP   BY 1;

我对total_space_usedpct_used的计算特别好奇。考虑像这样的倾斜表是否“合适”?

1 个答案:

答案 0 :(得分:2)

绝对考虑到倾斜。您的列free_space为您提供了所有现有表格倾斜的可用空间。 此外,free_space假定所有未来的表都是完美分布的。没有倾斜。