使用文字快速查询,使用变量快速查询-Oracle / Toad

时间:2019-08-10 16:01:25

标签: sql oracle performance variables toad

我有2个查询:字面量为13s,变量为60ms。

我尝试将“ to_date”用原义表示,但13秒没有改变

这在13秒内花费49.338,基数4(全表访问):

select *
from registros, pagamentos
where 
    REGISTROS.DT_REGISTRO <=  '10/06/2019' and REGISTROS.DT_REGISTRO >= '10/06/2018'
    and dt_sistema<= '10/06/2019' and REGISTROS.DT_SISTEMA >= '10/06/2018'
    and REGISTROS.DT_COMPETENCIA <= '10/06/2019 'and REGISTROS.DT_COMPETENCIA >= '10/06/2018'
    and PAGAMENTOS.SQ_PAGAMENTO = REGISTROS.PAGTO_SQ_PAGAMENTO ;

此时间为60毫秒,费用为14.412,基数为1:

select * 
from registros, pagamentos
where 
    REGISTROS.DT_REGISTRO <= :p_data and REGISTROS.DT_REGISTRO >= :p_data2
    and dt_sistema<= :p_data  and REGISTROS.DT_SISTEMA >= :p_data2
    and REGISTROS.DT_COMPETENCIA <= :p_data  and REGISTROS.DT_COMPETENCIA >= :p_data2
    and PAGAMENTOS.SQ_PAGAMENTO = REGISTROS.PAGTO_SQ_PAGAMENTO ;

1 个答案:

答案 0 :(得分:0)