为什么这个查询在db2中这么慢?

时间:2014-07-07 13:13:00

标签: database performance db2 database-performance db2-luw

我面临的是查询效果,

SELECT PrivilegeID,ContainerDN,RoleContainerDN,ServiceProfile,ServiceDN,
        PrivilegeName,PrivilegeDescription,PrivilegeType,PrivilegeMappingType,
        PrivilegeIdentificationSource,AccessType,PrivilegeMapping,
        PrivilegeOwner,PrivilegeBackupOwner,PrivilegeAdminTeam,
        ProvisioningNotification,DeprovisioningNotification,Status,
        InActivatedByUser,InActivationDate,ISOSR,GroupProfileName 
FROM ITIMUSER.TableA 
WHERE (Status='A' OR Status='P') AND (GroupProfileName IS NULL OR 
        GroupProfileName='ALL' OR (GroupProfileName='PosAixGroupProfile' OR 
        GroupProfileName='PosAixRoleProfile' OR 
        GroupProfileName='PosAixUserAliasProfile')) AND (ServiceDN=? OR 
        ServiceDN='ALL')

在某些环境中,此查询大约需要50秒才能执行。我有这个查询的解释计划。 我调查了一下(无论我能找到什么,我都是DB performance engg的新手。) 我建议关注一些事情,

  1. 增加锁定列表大小
  2. 增加sortheap大小(但不确定多少,我认为它应该是< =行读取)
  3. 在servicedn和status列上添加了索引。(没多大帮助)
  4. 通过移除重度运算符来调整查询,例如' OR'通过使用' in'删除它们
  5. 有点改进但仍然是昂贵的查询。

    我为最长的问题道歉:) 你能看看这个exfmt输出并建议我更多可能的调音吗?

    数据库上下文:

    Parallelism:        None
    CPU Speed:      3.542582e-07
    Comm Speed:         100
    Buffer Pool size:   315392
    Sort Heap size:     1574
    Database Heap size:     2804
    Lock List size:     20000
    Maximum Lock List:  60
    Average Applications:   1
    Locks Available:    768000
    

    包上下文:

    SQL Type:       Dynamic
    Optimization Level:     5
    Blocking:       Block All Cursors
    Isolation Level:    Cursor Stability
    

    ----------------声明1第201节----------------     QUERYNO:1     QUERYTAG:CLP
        声明类型:选择     可更新的:没有     可删除:没有     查询度:1

    原始声明:

    SELECT PrivilegeID,ContainerDN,RoleContainerDN,ServiceProfile,ServiceDN,
            PrivilegeName,PrivilegeDescription,PrivilegeType,PrivilegeMappingType,
            PrivilegeIdentificationSource,AccessType,PrivilegeMapping,
            PrivilegeOwner,PrivilegeBackupOwner,PrivilegeAdminTeam,
            ProvisioningNotification,DeprovisioningNotification,Status,
            InActivatedByUser,InActivationDate,ISOSR,GroupProfileName 
    FROM ITIMUSER.TableA 
    WHERE (Status='A' OR Status='P') AND (GroupProfileName IS NULL OR 
            GroupProfileName='ALL' OR (GroupProfileName='PosAixGroupProfile' OR 
            GroupProfileName='PosAixRoleProfile' OR 
            GroupProfileName='PosAixUserAliasProfile')) AND (ServiceDN=? OR 
            ServiceDN='ALL')
    

    优化声明:

    SELECT Q6.PRIVILEGEID AS "PRIVILEGEID", Q6.CONTAINERDN AS "CONTAINERDN", 
            Q6.ROLECONTAINERDN AS "ROLECONTAINERDN", Q6.SERVICEPROFILE AS 
            "SERVICEPROFILE", Q6.SERVICEDN AS "SERVICEDN", Q6.PRIVILEGENAME AS 
            "PRIVILEGENAME", Q6.PRIVILEGEDESCRIPTION AS "PRIVILEGEDESCRIPTION", 
            Q6.PRIVILEGETYPE AS "PRIVILEGETYPE", Q6.PRIVILEGEMAPPINGTYPE AS 
            "PRIVILEGEMAPPINGTYPE", Q6.PRIVILEGEIDENTIFICATIONSOURCE AS 
            "PRIVILEGEIDENTIFICATIONSOURCE", Q6.ACCESSTYPE AS "ACCESSTYPE", 
            Q6.PRIVILEGEMAPPING AS "PRIVILEGEMAPPING", Q6.PRIVILEGEOWNER AS 
            "PRIVILEGEOWNER", Q6.PRIVILEGEBACKUPOWNER AS "PRIVILEGEBACKUPOWNER", 
            Q6.PRIVILEGEADMINTEAM AS "PRIVILEGEADMINTEAM", 
            Q6.PROVISIONINGNOTIFICATION AS "PROVISIONINGNOTIFICATION", 
            Q6.DEPROVISIONINGNOTIFICATION AS "DEPROVISIONINGNOTIFICATION", 
            Q6.STATUS AS "STATUS", Q6.INACTIVATEDBYUSER AS "INACTIVATEDBYUSER", 
            Q6.INACTIVATIONDATE AS "INACTIVATIONDATE", Q6.ISOSR AS "ISOSR", 
            Q6.GROUPPROFILENAME AS "GROUPPROFILENAME" 
    FROM ITIMUSER.TableA AS Q6 
    WHERE Q6.SERVICEDN IN (:?, 'ALL') AND Q6.STATUS IN ('A', 'P') AND 
            ((Q6.GROUPPROFILENAME IS NULL OR (Q6.GROUPPROFILENAME = 'ALL')) OR 
            (((Q6.GROUPPROFILENAME = 'PosAixGroupProfile') OR 
            (Q6.GROUPPROFILENAME = 'PosAixRoleProfile')) OR (Q6.GROUPPROFILENAME 
            = 'PosAixUserAliasProfile')))
    

    访问计划:

    Total Cost:         778.169
    Query Degree:       0
    
                                     Rows 
                                    RETURN
                                    (   1)
                                     Cost 
                                      I/O 
                                      |
                                    24535.8 
                                    ^HSJOIN
                                    (   2)
                                    778.169 
                                    647.617 
                         /------------+------------\
                      24859                           2 
                     FETCH                         TBSCAN
                     (   3)                        (   9)
                     772.755                     5.31387e-05 
                     647.617                          0 
                 /-----+------\                      |
             30140.5          144068                  2 
             RIDSCN       TABLE: ITIMUSER     TABFNC: SYSIBM  
             (   4)   TableA       GENROW
             115.713            Q6                   Q1
             28.6349 
         /-----+------\
     6.47526           30134 
     SORT             SORT  
     (   5)           (   7)
     7.59396          108.119 
        1             27.6349 
       |                |
     6.47526           30134 
     IXSCAN           IXSCAN
     (   6)           (   8)
     7.59281          89.201 
        1             27.6349 
       |                |
     144068           144068 
    

    索引:ITIMUSER指数:ITIMUSER   SVCDN_STATUS SVCDN_STATUS        Q6 Q6

    扩展诊断信息:

    此声明没有扩展的诊断信息。

    计划详情:

    1) RETURN: (Return Result)
        Cumulative Total Cost:      778.169
        Cumulative CPU Cost:        2.19454e+08
        Cumulative I/O Cost:        647.617
        Cumulative Re-Total Cost:   778.169
        Cumulative Re-CPU Cost:     2.19454e+08
        Cumulative Re-I/O Cost:     647.617
        Cumulative First Row Cost:  778.169
        Estimated Bufferpool Buffers:   649.382
    
        Arguments:
        ---------
        BLDLEVEL: (Build level)
            DB2 v9.5.0.3 : s090225
        HEAPUSE : (Maximum Statement Heap Usage)
            160 Pages
        STMTHEAP: (Statement heap size)
            6402
    
        Input Streams:
        -------------
            12) From Operator #2
    
                Estimated number of rows:   24535.8
                Number of columns:      22
                Subquery predicate ID:      Not Applicable
    
                Column Names:
                ------------
                +Q7.GROUPPROFILENAME+Q7.ISOSR
                +Q7.INACTIVATIONDATE+Q7.INACTIVATEDBYUSER
                +Q7.STATUS+Q7.DEPROVISIONINGNOTIFICATION
                +Q7.PROVISIONINGNOTIFICATION
                +Q7.PRIVILEGEADMINTEAM+Q7.PRIVILEGEBACKUPOWNER
                +Q7.PRIVILEGEOWNER+Q7.PRIVILEGEMAPPING
                +Q7.ACCESSTYPE
                +Q7.PRIVILEGEIDENTIFICATIONSOURCE
                +Q7.PRIVILEGEMAPPINGTYPE+Q7.PRIVILEGETYPE
                +Q7.PRIVILEGEDESCRIPTION+Q7.PRIVILEGENAME
                +Q7.SERVICEDN+Q7.SERVICEPROFILE
                +Q7.ROLECONTAINERDN+Q7.CONTAINERDN
                +Q7.PRIVILEGEID
    
    
    2) HSJOIN: (Hash Join)
        Cumulative Total Cost:      778.169
        Cumulative CPU Cost:        2.19454e+08
        Cumulative I/O Cost:        647.617
        Cumulative Re-Total Cost:   778.169
        Cumulative Re-CPU Cost:     2.19454e+08
        Cumulative Re-I/O Cost:     647.617
        Cumulative First Row Cost:  778.169
        Estimated Bufferpool Buffers:   649.382
    
        Arguments:
        ---------
        BITFLTR : (Hash Join Bit Filter used)
            FALSE
        EARLYOUT: (Early Out flag)
            LEFT
        HASHCODE: (Hash Code Size)
            24 BIT
        TEMPSIZE: (Temporary Table Page Size)
            32768
    
        Predicates:
        ----------
        2) Predicate used in Join
            Comparison Operator:        Equal (=)
            Subquery Input Required:    No
            Filter Factor:          0.4935
    
            Predicate Text:
            --------------
            (Q6.STATUS = Q2.$C0)
    
    
        Input Streams:
        -------------
            9) From Operator #3
    
                Estimated number of rows:   24859
                Number of columns:      22
                Subquery predicate ID:      Not Applicable
    
                Column Names:
                ------------
                +Q6.ISOSR+Q6.INACTIVATIONDATE
                +Q6.INACTIVATEDBYUSER
                +Q6.DEPROVISIONINGNOTIFICATION
                +Q6.PROVISIONINGNOTIFICATION
                +Q6.PRIVILEGEADMINTEAM+Q6.PRIVILEGEBACKUPOWNER
                +Q6.PRIVILEGEOWNER+Q6.PRIVILEGEMAPPING
                +Q6.ACCESSTYPE
                +Q6.PRIVILEGEIDENTIFICATIONSOURCE
                +Q6.PRIVILEGEMAPPINGTYPE+Q6.PRIVILEGETYPE
                +Q6.PRIVILEGEDESCRIPTION+Q6.PRIVILEGENAME
                +Q6.SERVICEPROFILE+Q6.ROLECONTAINERDN
                +Q6.CONTAINERDN+Q6.PRIVILEGEID+Q6.SERVICEDN
                +Q6.GROUPPROFILENAME+Q6.STATUS
    
            11) From Operator #9
    
                Estimated number of rows:   2
                Number of columns:      1
                Subquery predicate ID:      Not Applicable
    
                Column Names:
                ------------
                +Q2.$C0
    
    
        Output Streams:
        --------------
            12) To Operator #1
    
                Estimated number of rows:   24535.8
                Number of columns:      22
                Subquery predicate ID:      Not Applicable
    
                Column Names:
                ------------
                +Q7.GROUPPROFILENAME+Q7.ISOSR
                +Q7.INACTIVATIONDATE+Q7.INACTIVATEDBYUSER
                +Q7.STATUS+Q7.DEPROVISIONINGNOTIFICATION
                +Q7.PROVISIONINGNOTIFICATION
                +Q7.PRIVILEGEADMINTEAM+Q7.PRIVILEGEBACKUPOWNER
                +Q7.PRIVILEGEOWNER+Q7.PRIVILEGEMAPPING
                +Q7.ACCESSTYPE
                +Q7.PRIVILEGEIDENTIFICATIONSOURCE
                +Q7.PRIVILEGEMAPPINGTYPE+Q7.PRIVILEGETYPE
                +Q7.PRIVILEGEDESCRIPTION+Q7.PRIVILEGENAME
                +Q7.SERVICEDN+Q7.SERVICEPROFILE
                +Q7.ROLECONTAINERDN+Q7.CONTAINERDN
                +Q7.PRIVILEGEID
    
    
    3) FETCH : (Fetch)
        Cumulative Total Cost:      772.755
        Cumulative CPU Cost:        2.0417e+08
        Cumulative I/O Cost:        647.617
        Cumulative Re-Total Cost:   54.5714
        Cumulative Re-CPU Cost:     1.54044e+08
        Cumulative Re-I/O Cost:     0
        Cumulative First Row Cost:  123.283
        Estimated Bufferpool Buffers:   649.382
    
        Arguments:
        ---------
        JN INPUT: (Join input leg)
            OUTER
        MAX RIDS: (Maximum RIDs per list prefetch request)
            1024
        PREFETCH: (Type of Prefetch)
            LIST
        ROWLOCK : (Row Lock intent)
            NEXT KEY SHARE
        TABLOCK : (Table Lock intent)
            INTENT SHARE
        TBISOLVL: (Table access Isolation Level)
            CURSOR STABILITY
    
        Predicates:
        ----------
        4) Sargable Predicate
            Comparison Operator:        In List (IN), evaluated by binary search (list sorted at run-time)
            Subquery Input Required:    No
            Filter Factor:          0.20921
    
            Predicate Text:
            --------------
            Q6.SERVICEDN IN (:?, 'ALL')
    
        9) Sargable Predicate
            Comparison Operator:        Not Applicable
            Subquery Input Required:    No
            Filter Factor:          0.824771
    
            Predicate Text:
            --------------
            ((Q6.GROUPPROFILENAME IS NULL OR (Q6.GROUPPROFILENAME 
                    = 'ALL')) OR (((Q6.GROUPPROFILENAME = 
                    'PosAixGroupProfile') OR (Q6.GROUPPROFILENAME 
                    = 'PosAixRoleProfile')) OR 
                    (Q6.GROUPPROFILENAME = 
                    'PosAixUserAliasProfile')))
    
    
        Input Streams:
        -------------
            7) From Operator #4
    
                Estimated number of rows:   30140.5
                Number of columns:      1
                Subquery predicate ID:      Not Applicable
    
                Column Names:
                ------------
                +Q6.$RID$(A)
    
            8) From Object ITIMUSER.TableA
    
                Estimated number of rows:   144068
                Number of columns:      22
                Subquery predicate ID:      Not Applicable
    
                Column Names:
                ------------
                +Q6.ISOSR+Q6.INACTIVATIONDATE
                +Q6.INACTIVATEDBYUSER
                +Q6.DEPROVISIONINGNOTIFICATION
                +Q6.PROVISIONINGNOTIFICATION
                +Q6.PRIVILEGEADMINTEAM+Q6.PRIVILEGEBACKUPOWNER
                +Q6.PRIVILEGEOWNER+Q6.PRIVILEGEMAPPING
                +Q6.ACCESSTYPE
                +Q6.PRIVILEGEIDENTIFICATIONSOURCE
                +Q6.PRIVILEGEMAPPINGTYPE+Q6.PRIVILEGETYPE
                +Q6.PRIVILEGEDESCRIPTION+Q6.PRIVILEGENAME
                +Q6.SERVICEPROFILE+Q6.ROLECONTAINERDN
                +Q6.CONTAINERDN+Q6.PRIVILEGEID+Q6.SERVICEDN
                +Q6.GROUPPROFILENAME+Q6.STATUS
    
    
        Output Streams:
        --------------
            9) To Operator #2
    
                Estimated number of rows:   24859
                Number of columns:      22
                Subquery predicate ID:      Not Applicable
    
                Column Names:
                ------------
                +Q6.ISOSR+Q6.INACTIVATIONDATE
                +Q6.INACTIVATEDBYUSER
                +Q6.DEPROVISIONINGNOTIFICATION
                +Q6.PROVISIONINGNOTIFICATION
                +Q6.PRIVILEGEADMINTEAM+Q6.PRIVILEGEBACKUPOWNER
                +Q6.PRIVILEGEOWNER+Q6.PRIVILEGEMAPPING
                +Q6.ACCESSTYPE
                +Q6.PRIVILEGEIDENTIFICATIONSOURCE
                +Q6.PRIVILEGEMAPPINGTYPE+Q6.PRIVILEGETYPE
                +Q6.PRIVILEGEDESCRIPTION+Q6.PRIVILEGENAME
                +Q6.SERVICEPROFILE+Q6.ROLECONTAINERDN
                +Q6.CONTAINERDN+Q6.PRIVILEGEID+Q6.SERVICEDN
                +Q6.GROUPPROFILENAME+Q6.STATUS
    
    
    4) RIDSCN: (Row Identifier Scan)
        Cumulative Total Cost:      115.713
        Cumulative CPU Cost:        1.05646e+08
        Cumulative I/O Cost:        28.6349
        Cumulative Re-Total Cost:   21.0693
        Cumulative Re-CPU Cost:     5.94745e+07
        Cumulative Re-I/O Cost:     0
        Cumulative First Row Cost:  115.712
        Estimated Bufferpool Buffers:   30.4006
    
        Arguments:
        ---------
        NUMROWS : (Estimated number of rows)
            30141
    
        Input Streams:
        -------------
            3) From Operator #5
    
                Estimated number of rows:   6.47526
                Number of columns:      1
                Subquery predicate ID:      Not Applicable
    
                Column Names:
                ------------
                +Q6.$RID$(A)
    
            6) From Operator #7
    
                Estimated number of rows:   30134
                Number of columns:      1
                Subquery predicate ID:      Not Applicable
    
                Column Names:
                ------------
                +Q6.$RID$(A)
    
    
        Output Streams:
        --------------
            7) To Operator #3
    
                Estimated number of rows:   30140.5
                Number of columns:      1
                Subquery predicate ID:      Not Applicable
    
                Column Names:
                ------------
                +Q6.$RID$(A)
    
    
    5) SORT  : (Sort)
        Cumulative Total Cost:      7.59396
        Cumulative CPU Cost:        95860.9
        Cumulative I/O Cost:        1
        Cumulative Re-Total Cost:   0.0156471
        Cumulative Re-CPU Cost:     44168.7
        Cumulative Re-I/O Cost:     0
        Cumulative First Row Cost:  7.59396
        Estimated Bufferpool Buffers:   2
    
        Arguments:
        ---------
        DUPLWARN: (Duplicates Warning flag)
            TRUE
        NUMROWS : (Estimated number of rows)
            7
        ROWWIDTH: (Estimated width of rows)
            20
        SORTKEY : (Sort Key column)
            1: Q6.$RID$(A)
        TEMPSIZE: (Temporary Table Page Size)
            32768
        UNIQUE  : (Uniqueness required flag)
            TRUE
    
        Input Streams:
        -------------
            2) From Operator #6
    
                Estimated number of rows:   6.47526
                Number of columns:      2
                Subquery predicate ID:      Not Applicable
    
                Column Names:
                ------------
                +Q6.SERVICEDN(A)+Q6.STATUS(A)
    
    
        Output Streams:
        --------------
            3) To Operator #4
    
                Estimated number of rows:   6.47526
                Number of columns:      1
                Subquery predicate ID:      Not Applicable
    
                Column Names:
                ------------
                +Q6.$RID$(A)
    
    
    6) IXSCAN: (Index Scan)
        Cumulative Total Cost:      7.59281
        Cumulative CPU Cost:        92629.7
        Cumulative I/O Cost:        1
        Cumulative Re-Total Cost:   0.0156471
        Cumulative Re-CPU Cost:     44168.7
        Cumulative Re-I/O Cost:     0
        Cumulative First Row Cost:  7.58887
        Estimated Bufferpool Buffers:   2
    
        Arguments:
        ---------
        MAXPAGES: (Maximum pages for prefetch)
            1
        PREFETCH: (Type of Prefetch)
            NONE
        ROWLOCK : (Row Lock intent)
            NONE
        SCANDIR : (Scan Direction)
            FORWARD
        TABLOCK : (Table Lock intent)
            INTENT NONE
        TBISOLVL: (Table access Isolation Level)
            CURSOR STABILITY
    
        Predicates:
        ----------
        7) Start Key Predicate
            Comparison Operator:        Equal (=)
            Subquery Input Required:    No
            Filter Factor:          4.49458e-05
    
            Predicate Text:
            --------------
            (Q6.SERVICEDN = :?)
    
        7) Stop Key Predicate
            Comparison Operator:        Equal (=)
            Subquery Input Required:    No
            Filter Factor:          4.49458e-05
    
            Predicate Text:
            --------------
            (Q6.SERVICEDN = :?)
    
    
        Input Streams:
        -------------
            1) From Object ITIMUSER.SVCDN_STATUS
    
                Estimated number of rows:   144068
                Number of columns:      3
                Subquery predicate ID:      Not Applicable
    
                Column Names:
                ------------
                +Q6.SERVICEDN(A)+Q6.STATUS(A)+Q6.$RID$
    
    
        Output Streams:
        --------------
            2) To Operator #5
    
                Estimated number of rows:   6.47526
                Number of columns:      2
                Subquery predicate ID:      Not Applicable
    
                Column Names:
                ------------
                +Q6.SERVICEDN(A)+Q6.STATUS(A)
    
    
    7) SORT  : (Sort)
        Cumulative Total Cost:      108.119
        Cumulative CPU Cost:        1.05551e+08
        Cumulative I/O Cost:        27.6349
        Cumulative Re-Total Cost:   18.3837
        Cumulative Re-CPU Cost:     5.18936e+07
        Cumulative Re-I/O Cost:     0
        Cumulative First Row Cost:  108.119
        Estimated Bufferpool Buffers:   28.4006
    
        Arguments:
        ---------
        DUPLWARN: (Duplicates Warning flag)
            TRUE
        NUMROWS : (Estimated number of rows)
            30134
        ROWWIDTH: (Estimated width of rows)
            20
        SORTKEY : (Sort Key column)
            1: Q6.$RID$(A)
        TEMPSIZE: (Temporary Table Page Size)
            32768
        UNIQUE  : (Uniqueness required flag)
            TRUE
    
        Input Streams:
        -------------
            5) From Operator #8
    
                Estimated number of rows:   30134
                Number of columns:      2
                Subquery predicate ID:      Not Applicable
    
                Column Names:
                ------------
                +Q6.SERVICEDN(A)+Q6.STATUS(A)
    
    
        Output Streams:
        --------------
            6) To Operator #4
    
                Estimated number of rows:   30134
                Number of columns:      1
                Subquery predicate ID:      Not Applicable
    
                Column Names:
                ------------
                +Q6.$RID$(A)
    
    
    8) IXSCAN: (Index Scan)
        Cumulative Total Cost:      89.201
        Cumulative CPU Cost:        5.21489e+07
        Cumulative I/O Cost:        27.6349
        Cumulative Re-Total Cost:   18.3837
        Cumulative Re-CPU Cost:     5.18936e+07
        Cumulative Re-I/O Cost:     0
        Cumulative First Row Cost:  7.58887
        Estimated Bufferpool Buffers:   28.4006
    
        Arguments:
        ---------
        MAXPAGES: (Maximum pages for prefetch)
            27
        PREFETCH: (Type of Prefetch)
            SEQUENTIAL
        ROWLOCK : (Row Lock intent)
            NONE
        SCANDIR : (Scan Direction)
            FORWARD
        TABLOCK : (Table Lock intent)
            INTENT NONE
        TBISOLVL: (Table access Isolation Level)
            CURSOR STABILITY
    
        Predicates:
        ----------
        8) Start Key Predicate
            Comparison Operator:        Equal (=)
            Subquery Input Required:    No
            Filter Factor:          0.209165
    
            Predicate Text:
            --------------
            (Q6.SERVICEDN = 'ALL')
    
        8) Stop Key Predicate
            Comparison Operator:        Equal (=)
            Subquery Input Required:    No
            Filter Factor:          0.209165
    
            Predicate Text:
            --------------
            (Q6.SERVICEDN = 'ALL')
    
    
        Input Streams:
        -------------
            4) From Object ITIMUSER.SVCDN_STATUS
    
                Estimated number of rows:   144068
                Number of columns:      3
                Subquery predicate ID:      Not Applicable
    
                Column Names:
                ------------
                +Q6.SERVICEDN(A)+Q6.STATUS(A)+Q6.$RID$
    
    
        Output Streams:
        --------------
            5) To Operator #7
    
                Estimated number of rows:   30134
                Number of columns:      2
                Subquery predicate ID:      Not Applicable
    
                Column Names:
                ------------
                +Q6.SERVICEDN(A)+Q6.STATUS(A)
    
    
    9) TBSCAN: (Table Scan)
        Cumulative Total Cost:      5.31387e-05
        Cumulative CPU Cost:        150
        Cumulative I/O Cost:        0
        Cumulative Re-Total Cost:   5.31387e-05
        Cumulative Re-CPU Cost:     150
        Cumulative Re-I/O Cost:     0
        Cumulative First Row Cost:  3.18832e-05
        Estimated Bufferpool Buffers:   0
    
        Arguments:
        ---------
        GENRVALS: (GENROW IN List values)
            VALUES ('A', 'P')
        JN INPUT: (Join input leg)
            INNER
        MAXPAGES: (Maximum pages for prefetch)
            ALL
        PREFETCH: (Type of Prefetch)
            NONE
        ROWLOCK : (Row Lock intent)
            NEXT KEY SHARE
        SCANDIR : (Scan Direction)
            FORWARD
        TABLOCK : (Table Lock intent)
            INTENT SHARE
        TBISOLVL: (Table access Isolation Level)
            CURSOR STABILITY
    
        Input Streams:
        -------------
            10) From Object SYSIBM.GENROW
    
                Estimated number of rows:   2
                Number of columns:      1
                Subquery predicate ID:      Not Applicable
    
                Column Names:
                ------------
                +Q1.NUMB
    
    
        Output Streams:
        --------------
            11) To Operator #2
    
                Estimated number of rows:   2
                Number of columns:      1
                Subquery predicate ID:      Not Applicable
    
                Column Names:
                ------------
                +Q2.$C0
    

    访问计划中使用的对象:

    Schema: ITIMUSER
    Name:   SVCDN_STATUS
    Type:   Index
            Time of creation:       2014-07-04-07.27.27.866382
            Last statistics update:     2014-07-04-09.37.29.120054
            Number of columns:      2
            Number of rows:         144068
            Width of rows:          -1
            Number of buffer pool pages:    2409
            Distinct row values:        No
            Tablespace name:        ENROLE_DATA       
            Tablespace overhead:        7.500000
            Tablespace transfer rate:   0.060000
            Source for statistics:      Single Node
            Prefetch page count:        32
            Container extent page count:    32
            Index clustering statistic:     94.000000
            Index leaf pages:       131
            Index tree levels:      2
            Index full key cardinality:     26559
            Index first key cardinality:    22249
            Index first 2 keys cardinality: 26559
            Index first 3 keys cardinality: -1
            Index first 4 keys cardinality: -1
            Index sequential pages:     130
            Index page density:         99
            Index avg sequential pages:     130
            Index avg gap between sequences:0
            Index avg random pages:     0
            Fetch avg sequential pages:     -1
            Fetch avg gap between sequences:-1
            Fetch avg random pages:     -1
            Index RID count:        144068
            Index deleted RID count:    0
            Index empty leaf pages:     0
            Base Table Schema:      ITIMUSER
            Base Table Name:        TableA
            Columns in index:
                SERVICEDN(A)
                STATUS(A)
    
    Schema: ITIMUSER
    Name:   TableA
    Type:   Table
            Time of creation:       2012-02-24-15.04.35.829088
            Last statistics update:     2014-07-04-09.37.29.120054
            Number of columns:      23
            Number of rows:         144068
            Width of rows:          542
            Number of buffer pool pages:    2409
            Number of data partitions:  1
            Distinct row values:        No
            Tablespace name:        ENROLE_DATA       
            Tablespace overhead:        7.500000
            Tablespace transfer rate:   0.060000
            Source for statistics:      Single Node
            Prefetch page count:        32
            Container extent page count:    32
            Table overflow record count:    0
            Table Active Blocks:        -1
            Average Row Compression Ratio:  0
            Percentage Rows Compressed:     0
            Average Compressed Row Size:    0
    
    Schema: SYSIBM  
    Name:   GENROW
    Type:   Table Function
            Time of creation:
            Last statistics update:
            Number of columns:      1
            Number of rows:         2
            Width of rows:          11
            Number of buffer pool pages:    -1
            Distinct row values:        No
            Source for statistics:      Single Node
    

    注意: AIX上的DB2 LUW 9.5。

1 个答案:

答案 0 :(得分:-1)

您是否尝试过 db2advis (db2advisor实用程序).​​..它会消失缺失的索引。

正如mustaccio建议的那样,我也会尝试在这些字段上创建一个索引:SERVICEDN,GROUPPROFILENAME和STATUS。

你期望多少行......对我来说,查询看起来有点奇怪,对于很多人来说,或者对于条件。

您是否曾尝试 REORG / RUNSTATS 表格?