简体   繁体   English

MySQL括号性能影响?

[英]MySQL parenthesis performance impact?

Say I had a MySQL query like this: 假设我有一个像这样的MySQL查询:

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: 如果我将CASE包装在括号中,因为我觉得它更具可读性:

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? 这会对查询产生性能影响吗?

Both these queries are semantically equivalent. 这两个查询在语义上都是等价的。 There shouldn't be any noticeable performance impact on using or not using parenthesis. 使用或不使用括号不应有任何明显的性能影响。

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. 您可以运行大数据测试来查找。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM