In MySQL 5.7, is there a way to limit specific type of queries up to a certain limit? select
queries for instance to be max 100 query at a time.
And is it doable to limit queries per host or user?
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It only takes a minute to sign up.
Sign up to join this communityYes you can. You can create users with resource limits, e.g.:
mysql> CREATE USER 'user_name'@'localhost' IDENTIFIED BY 'some_password'
-> WITH MAX_QUERIES_PER_HOUR 20
-> MAX_UPDATES_PER_HOUR 10
-> MAX_CONNECTIONS_PER_HOUR 5
-> MAX_USER_CONNECTIONS 2;
See here for more details: https://dev.mysql.com/doc/refman/5.7/en/user-resources.html
Since every connection can run at most one query at a time, for the specific case you are describing, you probably want to set MAX_USER_CONNECTIONS to 100.