优化SQL文
看看怎样优化?
这个 T_P2HP0040 表 数据有几万条 ,检索很慢
SELECT
ROWNUM AS No
,YD.KOJI_NO AS KOJI_NO
,YD.CONTAINER_NO AS CONTAINER_NO
,TP.CONTAINER_NAME AS CONTAINER_MEISHOO
,TP.GENCHAKU_DATE AS GENCHAKU_YMD
,YD.YOKYU_MESAI_NO AS YOKYU_MESAI_NO
,YD.KANBAN AS KANBAN
,YD.ZUMEN_NO AS ZUMEN_NO
,CM.KETTE_NOKI AS KETTE_NOKI
,CM.HACCHUSAKI_CODE AS MADOGUCHI_CODE
,CM.HACCHUSAKI_KAISHA_NAME AS HACCHUSAKI_KAISHA_NAME
,YD.TAN_I AS TAN_I
,YD.SEKKEI_SUURYOO AS SEKKEI_SUURYOO
,KT.JURYO_DATE AS JURYO_DATE
,KT.ISUGKN_SHINSE_DATE AS ISUGKN_SHINSE_DATE
,KT.KENSHU_END_DATE AS KENSHU_END_DATE
,YM.KOJI_NAME AS KOJI_NAME
FROM
DEN_YOKYU_MESAI_DETAIL_TBL
YD
,
(
SELECT
DISTINCT
KOOBAN
,CONTAINER_NO
,CONTAINER_NAME
,GENCHAKU_DATE
FROM
T_P2HP0040
WHERE
1 = 1
AND KOOBAN LIKE ' 0000001% '
AND GENCHAKU_DATE > = '20061001 '
AND GENCHAKU_DATE <= '20061231 '
)
TP
,V_DEN_CHUMON_MESAI_TBL CM
,V_DEN_KENSHU_TBL KT
,V_DEN_YOKYU_MESAI YM
WHERE
1 = 1
AND YD.KOJI_NO LIKE '0000001% '
AND YD.IHI_KIGYO_CODE = CM.IHI_KIGYO_CODE
AND YD.SYSTEM_KUBUN &