日期:2014-05-17  浏览次数:20987 次

关于sql优化——索引的使用
有一个视图如下:
Select   a.WKI_ID   AS   wf_workitem_id,  
              a.WKI_Name   AS   wf_workitem_name,   j.user_name   as   wf_from_user_name,
            a.WKI_CreateTime   AS   wf_create_date,a.wki_checkintime   as   wf_checkin_date,   a.WKI_Desc   AS   wf_workitem_url,
            a.wki_state,a.wki_user,a.wki_checkouttime,
            c.PRI_ID   AS   wf_process_instance_id,
            d.wka_applyman,
            g.BUSINESS_ID   AS   wf_business_id,
            g.PROJECT_ID   AS   wf_project_id,
            h.PRJ_TITLE   AS   wf_project_title,
            h.PRJ_BUSS_TYPE   AS   wf_business_type,
            h.PRJ_BUSS_NAME   AS   wf_business_name,   k.TIME_LIMIT   AS   wf_workitem_timelimit,
            k.TIME_USED   AS   wf_workitem_timeused,   k.TIME_LEFT   AS   wf_workitem_timeleft,  
            e.atd_id,e.atd_tamid
            l.act_max_timeout
            ,decode((select   count(*)   from   wf_workitem_urge   m   where   m.wki_id=a.wki_id),0, 'no ')   as   ifHaveUrge
FROM   WorkItem   a            
            INNER   JOIN   ActiInstance   b   ON   a.WKI_AtiID   =   b.ATI_ID
            INNER   JOIN   ProcInstance   c   ON   b.ATI_PriID   =   c.PRI_ID
            INNER   JOIN   WF_PROCESS_BUSINESS_REL   g   ON   c.PRI_ID   =   g.PRO_INST_ID
            INNER   JOIN   WF_PUBLIC_PROJECT_INFO   h   ON   g.PROJECT_ID   =   h.PROJECT_ID
            INNER   JOIN   ProcDefinition   f   ON   f.PRD_ID   =   c.PRI_PrdID
            LEFT   OUTER   JOIN   WorkitemApply   d   ON   a.WKI_ID   =   d.WKA_WkiID
            INNER   JOIN   ActiDefinition   e   ON   b.ATI_AtdID   =   e.ATD_ID                      
            LEFT   OUTER   JOIN   WF_WORKITEM_REL   i   ON   a.WKI_ID   =   i.TO_ITEM_ID
            LEFT   OUTER   JOIN   WF_USER   j   ON   j.USER_ID   =   i.FROM_USER_ID
            INNER   JOIN   WF_WORKITEM_PROCESS_TIME   k   ON   a.WKI_ID   =   k.WORKITEM_ID
            LEFT   JOIN   wf_actinstance_ext   l   On   b.ATI_ID   =   l.act_instance_id
            INNER   JOIN     workitemreledata   m   on   a.wki_id   =