Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

In MySQL is there any difference in performance between IFNULL(x,0) and CASE WHEN x IS NULL?

For example:

SELECT IFNULL(myNumber,0) AS myNumber

vs.

SELECT CASE WHEN myNumber IS NULL THEN 0 ELSE my Number END AS myNumber

It's certainly easier to write the first way, but is there any difference in performance?

2 Answers

Relevance
  • 1 decade ago
    Favorite Answer

    There's no real way of knowing which if better performance wise... unless you programmed the mysql engine, it'd be hard to know which would preform better.

    However.. i assume a prebuilt function would be better.. however.. the best way to test it would be to.. create a really large query using each one.. and see which one preforms faster.

  • Anonymous
    5 years ago

    Mysql Ifnull

Still have questions? Get your answers by asking now.