Queries, History & Metadata

Sometimes you might be looking at Looker-generated queries in your data warehouse to understand which are your slowest or most expensive. There’s an easy way to connect a query in your data warehouse with Looker’s internal system activity data.

Looker injects a comment into the SQL queries it generates with some helpful information, including the Looker user ID of the user who generated the query (whether from an Explore, Look, Dashboard or schedule) and the Looker history ID.

The History ID is what you’ll see in the URL when you click on ‘Details’ from the queries screen, and knowing this you can quickly pull up the details for a given query, which itself includes some useful info, including the Query ID user, source of the query, a link to run it in the Explore, the fields used, and the SQL.

It’s worth mentioning the difference between instances of History and Queries in Looker. A single query refers to the exact SQL that was generated and run, right down to any whitespace, whereas a history item refers to a run of a query.

You can see this for yourself in Looker’s internal System Activity History Explore (where you’d likely head next for information about troublesome queries) by observing that one Query ID can be related to many History IDs. The History Explore has a bunch of useful information available covering various aspects of Looker’s operation. Among the most useful are the clickable ‘link’ fields for Dashboards, Looks, and Explore queries - these let you get right to the content that is generating queries.

Previous
Previous

Clever Calculations

Next
Next

Managing Multiple LookML Projects