【发布时间】:2020-12-23 04:17:26
【问题描述】:
我有这个问题
update t_reconcile_biller b set status = case when exists (
SELECT i.credit_amount, i.recipt_no,
i.credit_acct_no, i.recon_date
FROM t_reconcile_t24 i
WHERE i.debit_acct_no = 'IDR1720600010001'
and b.col_4 = i.credit_amount
AND b.col_7 = i.recipt_no
AND b.col_2 = i.card_no
AND i.status <> 5
) then 1 else 2 end
where b.status <> 5 AND b.file_name in ('20200923-bnf', '20200922-bnf')
AND b.col_13 = 'DESTIONATION' AND b.col_4 <> '0'
AND b.col_14 in ('A', 'FC')
使用 postgres 运行需要 52 秒,其中 t_reconcile_biller 有 3.900 行,而 t_reconcile_t24 有 32.000 行。
我怎样才能使这个查询更快更高效?
【问题讨论】:
-
请用您正在使用的数据库标记您的问题
标签: sql postgresql performance