You might want to review Review these tips and make adjustments to increase your Presto queries performance.
For example, instead of using COUNT (DISTINCT x), use approx_distinct(x).
Tables should be joined in the order of a larger table to smaller tables.
Using a non-equi join condition slows down the query processing.
Columnar storage characteristics
Choosing too many columns slows down query processing.
Query result size
Generating too many rows takes time. Instead, use CREATE TABLE AS … or INSERT INTO or result_redirect magic comment.