这些语句在mysql过程中花费了太多时间?

时间:2017-04-20 17:43:48

标签: mysql database stored-procedures

MySQL程序声明太多时间可以任何人指导我如何解决它。执行这些声明需要13分钟以上。当我从程序中删除这些语句时,程序需要1秒钟才能执行。

if(pb.iLab = 1,
        0,
        ifnull(
           (SELECT sum(p_bi.dTotalAmount) amount
              FROM patientbillitem p_bi, patientbillpayment p_b
             WHERE     p_bi.vRefReceipt = p_b.vReceiptNo
                   AND p_b.iBillNo = pb.iBillNo
                   AND p_bi.vItemCode = pbi.vItemCode),
           0))
   - (ifnull(
         (SELECT sum(p_bi.discountAmount) amount
            FROM patientbillitem p_bi, patientbillpayment p_b
           WHERE     p_bi.vRefReceipt = p_b.vReceiptNo
                 AND p_b.iBillNo = pb.iBillNo
                 AND p_bi.vItemCode = pbi.vItemCode),
         0))
      dRefund,

任何人指导我在select语句中编写此dRefund的任何其他方法谢谢。

0 个答案:

没有答案