新的 Teradata Stats 功能。对一些事情感到困惑

New Teradata Stats features . Confused about a few things

我也处于同样的泥潭中,也许你们中的很多人都/曾经有过。 Teradata 14.1 在 .
此列为 1 个环境。结果是零 prolly 因为我们升级了一段时间之前但是在另一个 ( QA / test ) 环境中。它有值。

DBC.DBQLRuleTbl | TimeCreated


sel TimeCreated from DBC.DBQLRuleTbl where DBQLRuleTbl.UserID in ( sel OU.DatabaseId from DBC.ObjectUsage OU )

1 个环境中没有行。 我想做的是找出未使用的统计数据。我们只在过去几个月才开始使用 OU。 因此,当我使用此查询查找未使用的统计信息时,我得到了最后一个 col -1,因为 RuleTbl 没有与 OU table.

匹配的内容
        SELECT DBC.DBase.DatabaseName AS DatabaseName
          ,DBC.TVM.TVMName        AS TableName
          ,COALESCE(DBC.StatsTbl.StatsName
                   ,DBC.StatsTbl.ExpressionList
                   ,'SUMMARY')    AS StatName
          ,CURRENT_DATE - CAST(DBC.StatsTbl.CreateTimeStamp AS DATE) AS StatAge
          ,CASE
           WHEN DatabaseName = 'DBC'
           THEN -2  -- Logging Not Applicable
           WHEN DBC.StatsTbl.StatsType IN ('B', 'M')
           THEN -2  -- Logging Not Applicable on Temp tables (base and materialized)
           WHEN DBC.DBQLRuleTbl.TimeCreated IS NULL
           THEN -1  -- Logging Not Enabled
           WHEN DBC.DBQLRuleTbl.TimeCreated > DBC.StatsTbl.CreateTimeStamp
           THEN CURRENT_DATE - CAST(DBC.DBQLRuleTbl.TimeCreated AS DATE)
           ELSE CURRENT_DATE - CAST(DBC.StatsTbl.CreateTimeStamp AS DATE)
     END AS DaysStatLogged 
    FROM   DBC.StatsTbl LEFT JOIN  DBC.DBQLRuleTbl
               ON DBC.StatsTbl.DatabaseId = DBC.DBQLRuleTbl.UserID
              AND DBQLRuleTbl.ExtraField5 = 'T'   

          ,DBC.Dbase
          ,DBC.TVM      
    WHERE DBC.StatsTbl.DatabaseId = DBC.DBASE.DatabaseId
      AND DBC.StatsTbl.ObjectId   = DBC.TVM.TVMId
      AND NOT EXISTS (SELECT '1' FROM DBC.ObjectUsage OU
                      WHERE OU.UsageType  = 'STA'
                        AND OU.DatabaseId = DBC.StatsTbl.DatabaseId
                        AND OU.ObjectId   = DBC.StatsTbl.ObjectId
                        AND OU.FieldId    = DBC.StatsTbl.StatsId
                        AND CURRENT_DATE - CAST(OU.LastAccessTimeStamp AS DATE) < N
                     )
      --AND DaysStatLogged > N 

    /* I had to mute this criteria because  otherwise there will be no o/p for reasons mentioned above */

      AND DBC.StatsTbl.StatsId <> 0  
-- Do not qualify table-level SUMMARY statistics as unused
-- May get implicitly used but not recorded as used
and StatAge < N 

/* StatAge < N .I am not sure if this filter should be there- I added it to catch those stats that are as old OU. We dunno if stats older than OU ever got used before OU started */
                                     and databasename in  ( sel child    from  dbc.children where parent ='FINDB'  group by      1 )
    ORDER BY 1, 2, 3;

我正在尝试获取 FINDB 级联的统计信息,而不是系统范围的统计信息。 鉴于我的规则 Table 被搞砸了 - 上面的查询不是最接近符合要求的吗
"Find me stats for ALL Databases under FINDB that have not been used since OU was turned on"

查询可能没问题,因为它基于 Identifying Used, Unused and Missing Statistics,只需检查它是否 returns 您想要的。

但是您使用的是 TD14.10,Viewpoint 中的 Stats Manager 可以完成所有这些(甚至更多),如果您还没有使用它,您应该开始 Easing Into Using the New AutoStats Feature