Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why should not disable ONLY_FULL_GROUP_BY

During internet searching I see lot of questions now to disable ONLY_FULL_GROUP_BY feature, so it mean lot of developers have a trouble with writing SQL queries in this strict mode.

I know it pretty simple to disable this limitation, but now I ask a question: Why shouldn't I do this?

What problems or side effects will be involved by removing ONLY_FULL_GROUP_BY limitation?

like image 568
Slava Rozhnev Avatar asked Oct 22 '25 09:10

Slava Rozhnev


1 Answers

Without the strictness that ONLY_FULL_GROUP_BY enforces, you may:

  • not realize you have the wrong query;
  • be getting some columns that don't have a specific meaning;
  • the results that you are getting, may not be the results that appear on a different server, or on the the next upgrade, or when the query plan changes (added/deleted/updated data).

So listen to ONLY_FULL_GROUP_BY. Its a strong warning that your query isn't right. The error is simply saying your GROUP BY clause is incompatible with the set of results being returned. Other databases enforce it by default, and its users write better SQL as a result.

Ignoring warnings is like web developers that chmod a+rwx because they can't work out file permissions. Take the time to understand the environment in which you are working and you'll be better off for the experience. And so will the next person, potentially your future self, that looks at the SQL.

like image 121
danblack Avatar answered Oct 24 '25 02:10

danblack



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!