What would be the MySql overhead if using COALESCE on every SELECT column since I’m tired to get DBNUll errors in my VB app. Should I be worried about?
Select COALESCE(price_small_breed, 0), COALESCE(discount_small_breed, '') From tblServicePrice Where service_id = .... just some example found on net
Thanks in advance
No, you should not be worried about the overhead.
The only performance issue that I know of with
coalesce()is in some versions of SQL Server (not MySQL!), where the first argument gets evaluated twice when it is not NULL. This is a problem when it is expensive, such as a subquery.However, in general, the overhead for a built-in function will be minimal compared to the cost of moving data in and out of the database.
There is an exception in more complex queries, where use of a function such as
coalesce()can prevent an index being used for some operations. Once again, this doesn’t apply in your case.