0

select * from dbc.columnsXTeradata 13.10で実行すると、奇妙な問題が発生しました。非常に遅いです。しかし、teradata 12.0 では非常に高速です。Teradata 13.10 の場合、dbc ユーザーにいくつかの権限がないか、または他の理由でこの現象が発生します。

私は、columnsX が X ビューであることを知っています。

4

1 に答える 1

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;
于 2013-03-13T09:35:00.797 に答える