Use this guide to optimize your queries, making them faster and more reliable. Well-optimized queries are also easier for you to handle if you need to make changes.
Create lighter queries
The amount of data determines how long a query will take to run, so only select the fields that are vital in each query. The “Combine new results with old” setting can help to reduce the amount of data each query requests.
For example, if you’re querying the last two weeks of data using the date and campaign name, the query will have to calculate the selected metrics for each date per campaign. So even if you have only 4 campaigns, that will multiply the 14 days you are querying for 56 rows of data. This means your query will run 56 calculations — one for each row — for every metric you include.
Advanced settings can help reduce the size of a query, too. Here are a couple of useful settings for query optimization:
- “KEEP_RESULTS_ON_REFRESH_ERROR”: The data won’t be replaced with the error message. Even the most simple queries can have errors and the error message will replace the data. (When using this setting, the error message can be found on the “SupermetricsQueries” tab. This is hidden by default — navigate to Add-ons → Supermetrics → Manage queries to open it.)
- “RETURN_NO_DATA_RESULT”: A good setting to remember if you want to pre-create a query.
Queries that use Supermetrics filters are heavier than ones that don’t. However, the filtering tools included in Google Sheets itself can be really helpful in trimming down your data.
They allow you to manipulate the data faster and save filtered views for the future. Learn more in Google’s documentation.