我在teradata 13.10上执行select * from dbc.columnsX
时遇到了一个奇怪的问题。这很慢;但是在teradata 12.0上它非常快。对于teradata 13.10,dbc用户是否缺少某些权利,或者还有其他一些原因会导致这种现象。
我知道columnsX是X视图。
答案 0 :(得分:1)
我们遇到了同样的问题,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;