When a Looker Explore runs a database query, the query is executed in three phases, as follows:
The Explore query tracker displays the progress of an Explore query through these three phases.
If a query is taking a long time to execute, the query tracker can indicate which phase of the query is causing the performance issue. This is useful for identifying where performance problems may occur, and where optimization efforts can be the most effective.
To enable the query tracker, your Looker admin must enable the Explore Query Tracker Labs feature. Once enabled, the query tracker is displayed when an Explore is running as long as either the Explore Visualization panel or Data panel is open.
Query Initialization phase
During the Query Initialization phase, Looker is performing all of the tasks that are required before the query is sent to your database. The Query Initialization phase includes the following tasks:
- Compiling the LookML model
- Checking to see if any persistent derived tables (PDTs) will need to be built
- Generating the query SQL
- Acquiring the database connection
Running Query phase
The Running Query phase is when Looker contacts and queries your database and returns the results of the query. Performance issues during this phase could indicate issue with the external database, such as PDTs that take a long time to rebuild and may need to be optimized, or external database tables that may need optimization. The Running Query phase includes the following tasks:
- Building any PDTs in the database that are required for the Explore query
- Running the requested query on the database
Processing Results phase
During the Processing Results phase, Looker processes and renders the results of the query. The Processing Results phase includes the following tasks:
- Streaming query results to the cache
- Resolving table calculations
- Formatting the results of the Liquid templating language
- Merging queries together
- Calculating totals and subtotals
Using the query tracker to troubleshoot query performance issues
Once you have identified which phase of a query is encountering possible performance issues, you can use the following resources to help further identify query performance trends and anomalies:
The Understanding query performance metrics documentation page describes how to use the Query Performance Metrics Explore in System Activity to view detailed breakdowns of each query that is run from your Looker instance.
The Query initialization phase of the query tracker includes the events that are described in the Asynchronous worker phase, Initialization phase, and Connection handling phase of the Query Performance Metrics Explore.
The Running query phase of the query tracker includes the events that are described in the Main queries phase of the Query Performance Metrics Explore.
The Processing Results phase of the query tracker includes the events described in the Post-query phase of the Query Performance Metrics Explore.
For more information about optimizing the Running Query phase, see the Optimize query performance section of the Optimize Looker performance documentation page.
You can also use the Performance Recommendations dashboard from the list of System Activity dashboards to view opportunities to improve performance on your Looker instance.