Terminate long-running user-initiated queries

Hi,

This article talks about the ability to set a max_execution_time for archiving and “LIVE” queries, however; I can’t find any guidance on how to avoid the timeouts and performance issues we’re seeing when our users create complex or wide-ranging segments which effectively bring the server to it’s knees for all other users.

Is there a way to 1) defer these large queries to archiving and 2) inform the user and 3) terminate the query to avoid situations like this? Right now we see MySQL running at 100+% trying to respond to a user query while the server is essentially unusable for other users.

https://matomo.org/faq/how-to/how-can-i-automatically-stop-long-running-database-queries/