PHP查询循环缓慢

时间:2019-02-25 12:32:06

标签: php oracle

我在我的PHP代码上使用for循环。然后,我在这里输入select查询。

SELECT * FROM MEP_TBL_OUTPUT_DETAILS WHERE MODELID_FK = '" . $dModel['MODELID'] . "' AND RUNNING_DATE = TO_DATE('$logDate', 'YYYY-MM-DD hh24:mi:ss') AND TS_CODE = '" . $dDtl['TS_CODE_DESCRIPTION'] . "' AND SHIFT = 'Morning' AND QUANTITY_STATUS = 'OK' AND CONFIGURATIONID_FK = '" . $dDtl['CONFIGURATIONID'] . "'

包括循环的完整PHP代码是:

for($i = $readRowAfter; $i < count($linesAccept); $i++)
{
    $dateobjAccept = DateTime::createFromFormat($createFromFormat, $linesAccept[$i]);

    if($dateobjAccept < $toDateTime && $dateobjAccept > $fromDateTime)
    {
        $rowsintimespanAccept++;

        $logDate = $dateobjAccept->format('Y-m-d H:i:s');
        $logDateInsert = $dateobjAccept->format('d-M-Y H:i:s');

        $qChk = oci_parse($c1, "SELECT * FROM MEP_TBL_OUTPUT_DETAILS WHERE MODELID_FK = '" . $dModel['MODELID'] . "' AND RUNNING_DATE = TO_DATE('$logDate', 'YYYY-MM-DD hh24:mi:ss') AND TS_CODE = '" . $dDtl['TS_CODE_DESCRIPTION'] . "' AND SHIFT = 'Morning' AND QUANTITY_STATUS = 'OK' AND CONFIGURATIONID_FK = '" . $dDtl['CONFIGURATIONID'] . "'");
        oci_execute($qChk);
        if(oci_fetch($qChk) > 0)
        {
        }
        else
        {
            \\Insert Query
        }
    }
}

-

count($linesAccept) sometimes can be 2000 more.

然后,当我尝试运行代码时,它将在查询时缓慢进行。

我的问题有什么可能的方法来进行快速查询?

*我的嫌疑犯正在查询中。

0 个答案:

没有答案