Using persist_for in models and explores to specify query caching

  • 3 October 2016
  • 0 replies


The persist_for parameter can be applied to models, explores, and/or derived tables. The impact will be slightly different for each of these Looker objects. When used in an explore or model, the persist_for parameter will enable you to modify the amount of time that query results are cached.

Default Behavior

When no persist_for parameter is present in either the model or the explore, by default Looker caches the results of any query for 60 minutes. This means that any queries that are run will be stored within the Looker cache. If any of those queries are re-run within sixty minutes of being stored, the results displayed will be pulled from the cache, not the database. Any queries that are re-run after 60 minutes will return fresh results from the database. Read more about Looker default query caching behavior here.

Using persist_for only in a model

Setting the persist_for parameter within a model specifies the amount of time that queries should be cached for all explores within that model. In the example below, the model contains two explores, and the persist_for parameter is set to 15 minutes.

connection: my_connection

persist_for: 15 minutes;

include: “*.view.lookml”

explore: my_explore_1 {

persist_for: 2 minutes


explore: my_explore_2 {}

In this case, queries using my_explore_1 will be cached for 2 minutes before fresh results are returned.  Since no **persist_for** parameter is set within the definition for my_explore_2, this explore inherits the caching timeframe set within the model and will cache queries for 15 minutes.

0 replies

Be the first to reply!