zw605068753
CaperJasmine
采纳率20%
2020-03-26 14:40 阅读 103

SQL语句 parpering耗时很长 如何优化

SQL如下:
SELECT
*
FROM
(
(
SELECT
reg.FV_CUSTOMER_NAME username,
ass.FV_ASSESS_STATUS assStutas,
ass.FV_PRO_TYPE protype,
ass.FV_PRO_ADDR proaddr,
ass.FV_REG_CODE regcode,
ass.FD_CREATE_TIME createTime,
ass.FV_PRO_CODE proCode,
ass.FV_CITY_CODE cityCode,
ass.FN_PRO_AREA proArea,
ass.FN_FINAL_TOTAL finalTotal,
reg.FV_CUSTOMER_AREA cusarea
FROM
pgyw_assess ass,
brw_register reg
WHERE
ass.FV_OPE_MANAGER = reg.FN_REGIST_ID
AND reg.FN_REGIST_ID IN (
SELECT
FN_REGIST_ID
FROM
brw_register
WHERE
FN_COMPANY_ID IN (
SELECT
FN_CUSORG_ID
FROM
brw_cusorg
WHERE
FV_SEQS LIKE '%.298%'
)
)
)
UNION
(
SELECT
reg.FV_CUSTOMER_NAME username,
'3' AS assStutas,
ass.FV_PRO_TYPE protype,
ass.FV_PRO_ADDR proaddr,
ass.FV_REG_CODE regcode,
p.FD_CREATE_TIME createTime,
ass.FV_PRO_CODE proCode,
ass.FV_CITY_CODE cityCode,
ass.FN_PRO_AREA proArea,
ass.FN_FINAL_TOTAL finalTotal,
reg.FV_CUSTOMER_AREA cusarea
FROM
brw_ass_parper p,
brw_register reg,
pgyw_assess ass
WHERE
p.FN_REGIST_ID = reg.FN_REGIST_ID
AND ass.FN_ASSESS_ID = p.FN_ASSESS_ID
AND reg.FN_REGIST_ID IN (
SELECT
FN_REGIST_ID
FROM
brw_register
WHERE
FN_COMPANY_ID IN (
SELECT
FN_CUSORG_ID
FROM
brw_cusorg
WHERE
FV_SEQS LIKE '%.298%'
)
)
)
ORDER BY
createTime DESC
) a
WHERE
1 = 1
AND createTime BETWEEN '2019-01-01 00:00:00'
AND '2020-03-26 08:33:20'
AND createTime BETWEEN '1900-01-01 00:00:00'
AND '2019-02-01 23:59:59'
LIMIT 0,
15

explain如下:
图片说明

图片说明

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

相关推荐