24

Is there any difference in performance between the operator IS NULL and the function ISNULL()?

Thanatos
  • 42,585
  • 14
  • 91
  • 146
Wiliam
  • 3,714
  • 7
  • 36
  • 56
  • 1
    Pretty much the same, I think. http://dev.mysql.com/doc/refman/5.0/en/comparison-operators.html – Amadan Aug 20 '10 at 10:50

2 Answers2

15

This thread is similar, though not exactly on MySQL. According to the test shown there:

IS NULL is more efficient as it doesn't require a scan.

Seek is generally faster than a scan as it only includes qualifying records, while scan includes every row. It is explained in more detail here.

Another difference (though it's not performance) is their negation syntax:

IS NOT NULL  /* using NOT operator */
! ISNULL()  /* using exclamation mark */
Community
  • 1
  • 1
Geo
  • 12,666
  • 4
  • 40
  • 55
11

Looking into the MySQL manual, they seem to be synonyms really.

and even if they aren't, I would tend to trust the query optimizer to pick the best solution.

Geo
  • 12,666
  • 4
  • 40
  • 55
Pekka
  • 442,112
  • 142
  • 972
  • 1,088
  • 3
    I readed that too, but the ISNULL doc says that SHARES some special behaviors with IS NULL, that scared me. – Wiliam Aug 20 '10 at 10:54
  • @Wiliam good point. Maybe doing a test run is indeed the best way to go! – Pekka Aug 20 '10 at 10:55
  • 5
    Huh? In my understanding, "shares special behaviour" just means they're weird, but they're weird in the *same way*. – Amadan Aug 25 '10 at 18:37
  • @Wiliam, `isnull()` seems like a function, whereas `is null` is surely a "language feature". – Pacerier May 04 '15 at 10:28