在这里,我处于同一个泥潭中,也许很多人都曾经/过去过。 Teradata 14.1具有对象使用功能。
这个专栏是1 env。结果是零,因为我们在前一段时间升级了,但在另一个(QA /测试)环境中升级了。它有价值。
DBC.DBQLRuleTbl | TimeCreated
sel TimeCreated from DBC.DBQLRuleTbl where DBQLRuleTbl.UserID in ( sel OU.DatabaseId from DBC.ObjectUsage OU )
1 env中没有行。
我想要做的是找出未使用的统计数据。我们过去几个月才开始使用OU。
因此,当我使用此查询查找UNUSED统计信息时,我得到最后一个col -1,因为RuleTbl没有任何与OU表匹配的内容。
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级联的JST THE STATS而不是系统范围的统计数据。
鉴于我的规则表搞砸了 - 上面的查询是否最接近于适合账单
“找到我自从OU开启以来尚未使用的FINDB下所有数据库的统计数据”
答案 0 :(得分:1)
查询可能正常,因为它基于Identifying Used, Unused and Missing Statistics,只需检查它是否返回您想要的内容。
但你在TD14.10和Viewpoint中的统计管理器做了所有这些(以及更多),如果你不使用它,你应该开始{{3} }