Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there some kind of "strict performance mode" for MySQL?

Tags:

mysql

I'd like to setup one instance of MySQL to flat-out reject certain types of queries. For instance, any JOINs not using an index should just fail and die and show up on the application stack trace, instead of running slow and showing up on the slow_query_log with no easy way to tie it back to the actual test case that caused it.

Also, I'd like to disallow "*" (as in "SELECT * FROM ...") and have that throw essentially a syntax error. Anything which is questionable or dangerous from a MySQL performance perspective should just cause an error.

Is this possible? Other than hacking up MySQL internals... is there an easy way?

like image 505
Alex R Avatar asked Nov 15 '22 12:11

Alex R


1 Answers

If you really want to control what users/programmers do via SQL, you have to put a layer between MySQL and your code that restricts access, like an ORM that only allows for certain tables to be accessed, and only certain queries. You can then also check to make sure the tables have indexes, etc.

You won't be able to know for sure if a query uses an index or not though. That's decided by the query optimizer layer in the database and the logic can get quite complex.

like image 95
OverClocked Avatar answered Dec 10 '22 05:12

OverClocked