Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Parenthesis() and SQL Query Performance

Tags:

sql

In a where statement, does adding unnecessary parentheses ( ) affect SQL performance?

Example:

SELECT * FROM table
WHERE (name='John') AND (age='30')
  AND (address='Some Street') AND (height='510')
like image 262
Devin Dixon Avatar asked Aug 25 '26 01:08

Devin Dixon


2 Answers

No, not in any way that is significant.

The query is parsed once, at which stage some extra parentheses could mean a marginal difference in execution time, but you would have to have a whole lot of parentheses before that would even be possible to measure.

Once the query is parsed and execution starts, it will behave exactly the same as one that had no unneccesary parentheses. Only the actual operations are left.

like image 188
Guffa Avatar answered Aug 27 '26 16:08

Guffa


There's no difference. Perhaps you'll save a few nanoseconds of parsing overhead one way or the other, but srsly. :)

like image 43
intgr Avatar answered Aug 27 '26 15:08

intgr



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!