Home > Database > Mysql Tutorial > How Can I Limit the Execution Time of MySQL Queries?

How Can I Limit the Execution Time of MySQL Queries?

Susan Sarandon
Release: 2025-01-05 03:33:40
Original
340 people have browsed it

How Can I Limit the Execution Time of MySQL Queries?

Limiting Query Execution Time in MySQL

To ensure efficient query execution, it may be necessary to enforce a maximum execution time for SQL queries, similar to the set_time_limit() functionality in PHP.

Solution: Execution Time Limit in MySQL

Starting with MySQL 5.7.4, the MAX_EXECUTION_TIME() hint was introduced to limit the execution time of top-level read-only SELECT statements. This hint specifies the maximum execution time in milliseconds:

SELECT
/*+ MAX_EXECUTION_TIME(1000) */ --in milliseconds
*
FROM table;
Copy after login

Implementation Note:

This feature is only applicable to read-only SELECT statements. It was initially named MAX_EXECUTION_TIME() in MySQL 5.7.4 and was renamed to max_execution_time in MySQL 5.7.8

The above is the detailed content of How Can I Limit the Execution Time of MySQL Queries?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template