JohnnyFaldo
JohnnyFaldo

Reputation: 4161

MySQL parenthesis performance impact?

Say I had a MySQL query like this:

SELECT id,
       something,
       CASE colour
           WHEN 1 THEN 'not ripe' 
           WHEN 2 THEN 'ripe'
           ELSE 'rotten'
       END AS 'ripeness' 
FROM fruit 
WHERE fruit_type = 'apple'

If I wrapped the CASE in parenthesis because I find it more readable:

SELECT id,
       something,
       (CASE colour
           WHEN 1 THEN 'not ripe' 
           WHEN 2 THEN 'ripe'
           ELSE 'rotten'
       END) AS 'ripeness' 
FROM fruit 
WHERE fruit_type = 'apple'

Would that have a performance impact on the query?

Upvotes: 1

Views: 345

Answers (2)

Benny Ae
Benny Ae

Reputation: 2016

don't think so, only time difference should be the compiler to decode your parenthesis,they will be compiled into same binary.

You can run a big data test to find out.

Upvotes: 1

Mureinik
Mureinik

Reputation: 310993

Both these queries are semantically equivalent. There shouldn't be any noticeable performance impact on using or not using parenthesis.

Upvotes: 2

Related Questions