Query Memory Usage?

  • Do you have any idea why the order of the conditions in the follow code would cause SqlServer's memory usage to rise from 20M to 200M ?

    declare  @UWI_Equals VARCHAR(13)

     set @uwi_equals = '0014010606000'

     

    SELECT *

    FROM [Well]

    WHERE

       ((UWI = @UWI_Equals) OR (@UWI_Equals Is Null) )  --   small memory usage: 20M

    --   ((@UWI_Equals Is Null) OR (UWI = @UWI_Equals))   -- big memory usage:  200M+

    ORDER BY UWI ASC

  • Dunno,

     

    Or perhaps

    SELECT *

    FROM [Well]

    WHERE UWI = @UWI_Equals)

      AND @UWI_Equals Is NOT Null

    get rid of the OR Operator should be good

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply