Is there is any Performance issue while using ISNULL() in SQL Server?

后端 未结 8 1775
陌清茗
陌清茗 2020-12-15 06:51

I am using ISNULL in MS SQl server 2008, since my table is too huge, whether using of ISNULL may cause any thing to the performance ?.

Than

相关标签:
8条回答
  • 2020-12-15 07:11

    It depends on how you are useing it, but you can build execution plans in the both cases (with ISNULL() and without it) and compare the results.

    0 讨论(0)
  • 2020-12-15 07:14

    As it has been already mentioned it depends on how and where you are using it in your query. May be you might want to show the way you are using it in your query.

    Also I would recommend you to go over this - What makes a SQL statement sargable?

    0 讨论(0)
  • 2020-12-15 07:19

    Avoid using isNull in where clause. Refer This article.

    0 讨论(0)
  • 2020-12-15 07:21

    Yes it can. For optimizer is better rewrite the query (if possible) to form

    (Field = @x OR @x IS NULL)
    

    Because using functions in certain cases prevents from optimizer to use statistics and sometimes forced implicit datatype conversions

    0 讨论(0)
  • 2020-12-15 07:23

    Watch out if using ISNULL with a sub query as the replacement_value.

    Seems like it runs the sub query even if the check_expression value is not NULL which doesn't help performance.

    CASE performs as expected.

    0 讨论(0)
  • 2020-12-15 07:25

    If you need to use it, then any differences between ISNULL and alternatives like COALESCE or CASE are minuscule. Don't worry about it

    Any differences come from how datatypes are handled. COALESCE/CASE can add implicit data type conversions whereas ISNULL has simpler rules.

    Edit

    ISNULL in the SELECT list to suppress NULLS is trivial. The main work will done in processing rows and data. An extra ISNULL won't be measurable: Don't optimise prematurely

    0 讨论(0)
提交回复
热议问题