0
我在teradata 13.10上執行select * from dbc.columnsX
時遇到了一個奇怪的問題。它非常緩慢;但在Teradata 12.0上它速度非常快。對於teradata 13.10,dbc用戶是否缺少一些權利,或者還有其他一些原因導致了這種現象。爲什麼執行「select * from dbc.columnsX」對teradata來說很慢13.10
我知道columnsX是X視圖。
我在teradata 13.10上執行select * from dbc.columnsX
時遇到了一個奇怪的問題。它非常緩慢;但在Teradata 12.0上它速度非常快。對於teradata 13.10,dbc用戶是否缺少一些權利,或者還有其他一些原因導致了這種現象。爲什麼執行「select * from dbc.columnsX」對teradata來說很慢13.10
我知道columnsX是X視圖。
我們遇到了同樣的問題,Teradata向我們發送了x視圖的替換。
這裏是DBC.ColumnsX腳本:
REPLACE VIEW DBC.ColumnsX
AS
SELECT CAST(TRANSLATE(dbase.DatabaseName USING UNICODE_TO_LOCALE
WITH ERROR) AS CHAR(30)) (NAMED DatabaseName),
CAST(TRANSLATE(tvm.tvmname USING UNICODE_TO_LOCALE WITH ERROR)
AS CHAR(30)) (NAMED TableName),
CAST(TRANSLATE(tvfields.fieldname USING UNICODE_TO_LOCALE WITH ERROR)
AS CHAR(30)) (NAMED ColumnName),
CAST(tvfields.fieldformat AS CHAR(30)) (NAMED ColumnFormat),
CAST(tvfields.fieldtitle AS VARCHAR(60)) (NAMED ColumnTitle),
tvfields.SPParameterType(NAMED SPParameterType),
tvfields.fieldtype(NAMED ColumnType),
CAST(TRANSLATE(tvfields.UDTName USING UNICODE_TO_LOCALE WITH ERROR)
AS CHAR(30))(NAMED ColumnUDTName),
tvfields.maxlength(NAMED ColumnLength,FORMAT 'Z,ZZZ,ZZZ,ZZ9'),
tvfields.DefaultValue,
tvfields.Nullable,
tvfields.CommentString,
tvfields.TotalDigits(NAMED DecimalTotalDigits,FORMAT 'Z9'),
tvfields.ImpliedPoint(NAMED DecimalFractionalDigits,FORMAT 'Z9'),
tvfields.FieldId(NAMED ColumnId),
tvfields.UpperCaseFlag,
tvfields.Compressible,
NULL(NAMED CompressValue),
TRANSLATE(tvfields.ColumnCheck USING UNICODE_TO_LOCALE WITH ERROR)
(NAMED ColumnConstraint),
tvfields.CheckCount (NAMED ConstraintCount),
CAST(TRANSLATE(DB1.DatabaseName USING UNICODE_TO_LOCALE WITH ERROR)
AS CHAR(30)) (named CreatorName),
tvfields.CreateTimeStamp,
CAST(TRANSLATE(DB2.DatabaseName USING UNICODE_TO_LOCALE WITH ERROR)
AS CHAR(30)) (named LastAlterName),
tvfields.LastAlterTimeStamp,
tvfields.CharType,
tvfields.IdColType,
tvfields.AccessCount,
tvfields.LastAccessTimeStamp,
tvfields.CompressValueList,
tvfields.TimeDimension,
tvfields.VTCheckType,
tvfields.TTCheckType
FROM DBC.tvfields
LEFT OUTER JOIN DBC.Dbase DB1
ON DBC.tvfields.CreateUID = DB1.DatabaseID
LEFT OUTER JOIN DBC.Dbase DB2
ON DBC.tvfields.LastAlterUID = DB2.DatabaseID,
DBC.dbase, DBC.TVM
WHERE tvm.DatabaseId = dbase.DatabaseId
AND tvm.tvmid = tvfields.tableid
AND (tvm.tvmid IN
(/* IDs of tables accessible to the USER */
SELECT tvm.tvmid
FROM TVM, DBASE, ACCESSRIGHTS
WHERE tvm.tvmid <> '000000000000'xb
AND dbase.DataBaseNameI = USER
AND (
/* User has right on all in TVMs DB */
(tvm.DatabaseId = accessrights.DatabaseId AND
accessrights.tvmid = '000000000000'xb AND
accessrights.UserId = dbase.DatabaseId)
OR
/* TVMs DB has right granted to *PUBLIC* */
(tvm.DatabaseId = accessrights.DatabaseId AND
accessrights.tvmid = '000000000000'xb AND
accessrights.Userid = '00000300'xb)
)
union
SELECT tvm.tvmid
FROM TVM, DBASE, ACCESSRIGHTS
WHERE tvm.tvmid <> '000000000000'xb
AND dbase.DataBaseNameI = USER
AND (
/* User has right on this specific TVM */
(tvm.tvmid = accessrights.tvmid AND
accessrights.UserId=dbase.DatabaseId)
OR
/* Specific TVM has right granted to *PUBLIC* */
(tvm.tvmid = accessrights.tvmid AND
accessrights.UserId= '00000300'xb)
)
union
SELECT tvm.tvmid
FROM TVM, DBASE, OWNERS
WHERE tvm.tvmid <> '000000000000'xb
AND dbase.DataBaseNameI = USER
AND
/* User owns TVMs DB */
(tvm.DatabaseId = owners.owneeid AND
owners.ownerid = dbase.DatabaseId)
union
SELECT tvm.tvmid
FROM TVM , DBASE
WHERE tvm.tvmid <> '000000000000'xb
AND dbase.DataBaseNameI = USER
AND
/* User *IS* TVMs DB */
(tvm.DatabaseId = dbase.DatabaseId)
)
OR tvm.tvmid IN
(/* IDs of tables accessible to USER's roles */
SELECT tvm.tvmid
FROM TVM, ACCESSRIGHTS, ROLES
WHERE TVM.tvmid <> '000000000000'xb
AND Roles.RoleId = AccessRights.UserId
AND ROLE IS NOT NULL
AND AccessRights.UserId IN
(SELECT RoleAccr.RoleId
FROM DBC.Roles RoleAccr)
AND (
/* Role has right on all in TVMs DB */
(tvm.DatabaseId = accessrights.DatabaseId AND
accessrights.tvmid = '000000000000'xb)
)
AND (
(UPPER(ROLE) <> 'ALL' AND
/* Restrict to rights granted to current role */
/* and the roles nested within current role */
(Roles.RoleId =
(SELECT CurRole.RoleId
FROM DBC.Roles CurRole
WHERE CurRole.RoleNameI = ROLE)
OR
Roles.RoleId IN
(SELECT RG.RoleId
FROM DBC.RoleGrants RG,
DBC.Roles CurRole
WHERE RG.GranteeId = CurRole.RoleId AND
CurRole.RoleNameI = ROLE))
)
OR
(UPPER(ROLE) = 'ALL' AND
/* The current role is ALL. Restrict to rights from */
/* the roles directly granted to current user and */
/* nested roles within them */
(Roles.RoleId IN
(SELECT UsrRG.RoleId
FROM DBC.RoleGrants UsrRG,
DBC.Dbase UserDB
WHERE UsrRG.GranteeId = UserDB.DatabaseId AND
UserDB.DatabaseNameI = USER)
OR
Roles.RoleId IN
(SELECT RG.RoleId
FROM DBC.RoleGrants RG
WHERE RG.GranteeId in
(SELECT UsrRG.RoleId
FROM DBC.RoleGrants UsrRG,
DBC.Dbase UserDB
WHERE UsrRG.GranteeId = UserDB.DatabaseId AND
UserDB.DatabaseNameI = USER)))
)
)
UNION ALL
SELECT tvm.tvmid
FROM TVM, ACCESSRIGHTS, ROLES
WHERE TVM.tvmid <> '000000000000'xb
AND Roles.RoleId = AccessRights.UserId
AND ROLE IS NOT NULL
AND AccessRights.UserId IN
(SELECT RoleAccr.RoleId
FROM DBC.Roles RoleAccr)
AND (
/* Role has right on this specific TVM */
(tvm.tvmid = accessrights.tvmid)
)
AND (
(UPPER(ROLE) <> 'ALL' AND
/* Restrict to rights granted to current role */
/* and the roles nested within current role */
(Roles.RoleId =
(SELECT CurRole.RoleId
FROM DBC.Roles CurRole
WHERE CurRole.RoleNameI = ROLE)
OR
Roles.RoleId IN
(SELECT RG.RoleId
FROM DBC.RoleGrants RG,
DBC.Roles CurRole
WHERE RG.GranteeId = CurRole.RoleId AND
CurRole.RoleNameI = ROLE))
)
OR
(UPPER(ROLE) = 'ALL' AND
/* The current role is ALL. Restrict to rights from */
/* the roles directly granted to current user and */
/* nested roles within them */
(Roles.RoleId IN
(SELECT UsrRG.RoleId
FROM DBC.RoleGrants UsrRG,
DBC.Dbase UserDB
WHERE UsrRG.GranteeId = UserDB.DatabaseId AND
UserDB.DatabaseNameI = USER)
OR
Roles.RoleId IN
(SELECT RG.RoleId
FROM DBC.RoleGrants RG
WHERE RG.GranteeId in
(SELECT UsrRG.RoleId
FROM DBC.RoleGrants UsrRG,
DBC.Dbase UserDB
WHERE UsrRG.GranteeId = UserDB.DatabaseId AND
UserDB.DatabaseNameI = USER)))
)
)
)
) WITH CHECK OPTION;
什麼是「非常緩慢」和「非常快」是什麼意思?另外,您是否比較了兩個相同的Teradata系統,可能是因爲升級? – BellevueBob
考慮到X視圖的複雜性,是否可以在Teradata 12上收集統計信息並在Teradata 13.10上統計這些統計信息是丟失還是過時?您是使用角色還是在用戶級別管理訪問? –
我的意思是「非常緩慢」是有死亡的phenamon,但「非常快」不是,此外它不是升級只是測試兩個版本的數據庫。 –