Limit number of lines
During the creation phase, use a limit 100 in the query to maximize execution time for displaying the result.
Limit the number of columns
Select only the fields needed in the various tables. SELECT * is not recommended.
Creating temporary tables
It's not possible to create tables, so it's necessary to use CTE
Use date in UTC
To ensure that the recipient of the campaign receives the date and time in his timezone, the right date at the right times, has the right date, it is necessary to use the timezone functions on the date field added if this was reset to UTC when integrating into the database.
Use of partition_date
For tables containing a partition_date, it is recommended to use it in the query construction.
Use of LEFT JOIN
Instead of using NOT IN or NOT EXISTS, it is recommended to use LEFT JOIN to optimize the query execution time.