1

This is similar to the statement_timeout of postgresql.

I'm looking to have the query error if it takes longer than x seconds.

I'm aware of SET MAX_EXECUTION_TIME, but that only affects select queries, not update/insert queries.

1
  • MariaDB has one or two timeouts like what you are looking for.
    – Rick James
    Mar 20 at 19:42

1 Answer 1

2

If the time you are trying to limit is spent waiting for locks, you could use lock_wait_timeout (for metadata locks, default is 1 year) or innodb_lock_wait_timeout (for row locks, default is 50 seconds).

If the time is spent after locks have been acquired, that is the execution time is taking too long, then no, I don't think MySQL has any query timeout for INSERT/UPDATE.

2
  • I think the 50 is much too long. In my opinion, if you have a transaction lasting longer than 5 seconds, you have a structural problem.
    – Rick James
    Mar 20 at 19:41
  • I don't disagree with that. Nevertheless, the default innodb lock wait timeout value in current versions of MySQL is 50 seconds. Mar 20 at 20:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.