BETWEEN clause versus <= AND >=

前端 未结 8 1320
無奈伤痛
無奈伤痛 2020-12-14 05:54

Is there a performance difference between using a BETWEEN clause or using <= AND >= comparisons?

i.e. these two queries:

SELECT *  
  FROM table           


        
8条回答
  •  -上瘾入骨i
    2020-12-14 06:50

    There is no performance difference between the two example queries because BETWEEN is simply a shorthand way of expressing an inclusive range comparison. When Oracle parses the BETWEEN condition it will automatically expand out into separate comparison clauses:

    ex.

    SELECT *  
      FROM table
     WHERE column BETWEEN :lower_bound AND :upper_bound  
    

    ...will automatically become:

    SELECT *  
      FROM table
     WHERE :lower_bound <= column
       AND :upper_bound >= column
    

提交回复
热议问题