How does getdate() and IS NOT NULL affects the query performance?

  • Hi,

    I am using IS NOT NULL and getdate() in my stored procedure. See the code snippets below and advice me the perforamnce impact becase of this?

    WHERE [Item].[AvailableForRetailTxnDateTime] <= GETDATE() AND

    GETDATE() <= (CASE WHEN [Item].[UnavailableForRetailTxnDTime] IS NULL THEN GETDATE()

    ELSE [Item].[UnavailableForRetailTxnDTime]

    END)

    AND Item.BaseNam IS NOT NULL

    Thanks in advance,

    Sivaguru

     

  • I would recomend you trace the script yourself with and without the "getdate" and "is not null" statements. There may be many other factors that affect the performance of a given statement than just the ones you mention.

    However if you changed the section

    GETDATE() <= (CASE WHEN [Item].[UnavailableForRetailTxnDTime] IS NULL THEN GETDATE()

    ELSE [Item].[UnavailableForRetailTxnDTime]

    END)

    to

    GETDATE()<= ISNULL([Item].[UnavailableForRetailTxnDTime],GETDATE())

    you would do better

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

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