大表上的查询执行缓慢

时间:2019-06-18 09:54:36

标签: sql oracle query-optimization

我的查询大约需要1.8秒。有什么方法可以优化此查询?

这是执行计划:

execution plan

查询:

SELECT COALESCE("SMTAPP"."MF_MAJST"."DAT",  "LPA_P1"."Datum") AS "Dat",
       COALESCE("SMTAPP"."MF_MAJST"."OS_C", "LPA_P1"."MfKpracOsC") AS "OsC",
       COALESCE("SMTAPP"."MF_MAJST"."HOD_VYKON", 0 /* :p2 */ ) AS "HodVykon",
       COALESCE("LPA_P1"."PlCas",    0 /* :p4 */ ) AS "SumarZaDen",
       "LPA_P1"."Id" AS "PlId",
       "SMTAPP"."MF_MAJST"."PKH" AS "MajstId",
       "SMTAPP"."MF_KPRAC"."MENO" AS "Meno",
       "SMTAPP"."MF_KPRAC"."PRIEZVISKO" AS "Priezvisko",
       "SMTAPP"."MF_KPRAC"."OZ" AS "Oz"
FROM
(
  (
    (
      SELECT SUM(COALESCE("LPA_C2"."Cas", 0 /* :p6 */)) AS "PlCas",
             "SMTAPP"."MF_PRACOVNY_LIST"."MF_KPRAC_OS_C" AS "MfKpracOsC",
             "SMTAPP"."MF_PRACOVNY_LIST"."DATUM" AS "Datum",
             "SMTAPP"."MF_PRACOVNY_LIST"."ID" AS "Id"
      FROM
      (
        (
          SELECT "SMTAPP"."MP_PRACOVNY_LIST_HODINY"."CAS" AS "Cas",
                 "SMTAPP"."MP_PRACOVNY_LIST_HODINY"."MF_PRACOVNY_LIST_ID" AS "MfPracovnyListId"
          FROM
          (
            "SMTAPP"."MP_PRACOVNY_LIST_HODINY"
            LEFT JOIN "SMTAPP"."MC_PRACOVNY_LIST_TYP"
            ON        "SMTAPP"."MC_PRACOVNY_LIST_TYP"."ID" = "SMTAPP"."MP_PRACOVNY_LIST_HODINY"."MC_PRACOVNY_LIST_TYP_ID"
          )
          WHERE
          (
            (
              (
              "SMTAPP"."MC_PRACOVNY_LIST_TYP"."POCITAT_DO_ODPRAC_HODIN" = 1 /* :p7 */
              )
            )
          )
        ) "LPA_C2"
        RIGHT JOIN "SMTAPP"."MF_PRACOVNY_LIST"
        ON "SMTAPP"."MF_PRACOVNY_LIST"."ID" = "LPA_C2"."MfPracovnyListId"
      )
      GROUP BY "SMTAPP"."MF_PRACOVNY_LIST"."MF_KPRAC_OS_C",
               "SMTAPP"."MF_PRACOVNY_LIST"."DATUM",
               "SMTAPP"."MF_PRACOVNY_LIST"."ID"
    ) "LPA_P1" FULL
    JOIN "SMTAPP"."MF_MAJST"
    ON
    (
          "LPA_P1"."MfKpracOsC" = "SMTAPP"."MF_MAJST"."OS_C"
      AND "LPA_P1"."Datum" = "SMTAPP"."MF_MAJST"."DAT"
    )
  )
  LEFT JOIN "SMTAPP"."MF_KPRAC"
  ON "SMTAPP"."MF_KPRAC"."OS_C" = COALESCE("SMTAPP"."MF_MAJST"."OS_C", "LPA_P1"."MfKpracOsC")
)
WHERE
(
  (
    (
      COALESCE("SMTAPP"."MF_MAJST"."HOD_VYKON", 0 /* :p14 */) <> COALESCE("LPA_P1"."PlCas", 0 /* :p12 */)
    )
  )
)
AND rownum <= 15

0 个答案:

没有答案