Managing Presto Query Execution Time
By default, the Presto service limits query execution time to 48 hours.
You might want to limit some or all Presto queries to run for a shorter period. For example:
- You can limit execution time for ad hoc queries by default, to avoid unexpectedly high Presto costs.
- You can push users to choose Hive over Presto for large and long-running data pipeline jobs.
Contact Support to request custom limits on the following types of queries:
- Ad hoc queries from the console, and queries submitted through ODBC and JDBC
- Queries that run as scheduled queries or as steps in workflows
- Queries explicitly assigned to any named resource pool
The limits apply to queries created by any user.
If you want to override any other limits for a single query, you can apply the following query hint at the beginning of the query:
– set session query_max_execution_time='12h'
SELECT COUNT(*) FROM ALL_EVENTS;
If limits are set in your account, and you write a query with hint, then the smallest limit between account, resource-group, query-hint and global is used.
Supported time measures are d (days), h (hours), m (minutes), s (seconds).
Note: All Presto queries are limited to 48 hours runtime, regardless of any account-level policy or query hint.
If the limit specified in the query hint is longer than the configured limit, then the shorter configured limit still applies. For example, if a 1 hour limit is configured for ad hoc queries, then you can use the magic comment to limit a query to 5 minutes (5m) but not to increase the limit to 2 hours (2h).
You can run a query in a special overcommit resource pool if you want to extend the runtime beyond the query's normal limits. In this case, the limit specified in the query hint is greater than the query's normal limit.
For example, if there is a 30 minute limit configured on scheduled queries, you can run a longer query with the following query hints:
-- set property resource_group = 'overcommit'
-- set session query_max_execution_time = '1d'