如何优化此查询的执行时间?

时间:2015-03-10 11:00:06

标签: oracle11g

SELECT SHOWN0,
       SHOWN1,
       LVL_1,
       LVL_2,
       LVL_3,
       LVL_4
  FROM (SELECT CMS_Correspondence_Primary.Field0 SHOWN0,
               CMS_Correspondence_Primary.Field1_1 SHOWN1,
               (    SELECT LEVEL
                      FROM Links L
                     WHERE L.ParentType = 1 AND L.ParentId = 'UG205'
                START WITH L.ItemId = Items.ItemId
                CONNECT BY     L.ItemId = PRIOR L.ParentId
                           AND PRIOR L.ParentType = 2)
                  LVL_1,
               (    SELECT LEVEL
                      FROM Links L
                     WHERE L.ParentType = 1 AND L.ParentId = 'UG206'
                START WITH L.ItemId = Items.ItemId
                CONNECT BY     L.ItemId = PRIOR L.ParentId
                           AND PRIOR L.ParentType = 2)
                  LVL_2,
               (    SELECT LEVEL
                      FROM Links L
                     WHERE L.ParentType = 1 AND L.ParentId = 'UG230'
                START WITH L.ItemId = Items.ItemId
                CONNECT BY     L.ItemId = PRIOR L.ParentId
                           AND PRIOR L.ParentType = 2)
                  LVL_3,
               (    SELECT LEVEL
                      FROM Links L
                     WHERE L.ParentType = 1 AND L.ParentId = 'UG281'
                START WITH L.ItemId = Items.ItemId
                CONNECT BY     L.ItemId = PRIOR L.ParentId
                           AND PRIOR L.ParentType = 2)
                  LVL_4
          FROM Items, CMS_Correspondence_Primary
         WHERE     (    ( (    UPPER (CMS_Correspondence_Primary.Field1_1) LIKE
                                  UPPER ('%abc%')
                           AND CMS_Correspondence_Primary.Field1_1
                                  IS NOT NULL))
                    AND (    (CMS_Correspondence_Primary.Field12_1 = 210)
                         AND (1 = 1)
                         AND (1 = 1)
                         AND (1 = 1)
                         AND (1 = 1)))
               AND (Items.Status <> 1)
               AND (Items.ItemId = CMS_Correspondence_Primary.Field0))
       INNER_QUERY
 WHERE LVL_1 IS NULL AND LVL_2 IS NULL AND LVL_3 IS NULL AND LVL_4 IS NULL

此查询需要进行优化,因为执行需要很长时间。

0 个答案:

没有答案