Cached Queries

The purpose of this guide is to help you understand what caching is and when you may want to cache your query to speed up your analysis response. The follow-up piece to this guide on Cached Queries is the guide on the topic: Cached Datasets.

What is Caching?

Use Caching when you are ready to build on top of Keen Compute query results. This unlocks a few benefits: subsecond response times for customer-facing dashboards, and secondly leveraging the cached query’s pre-computed result does not count against your per-project query limit.

Cached Queries and Cached Datasets regularly perform the computation in advance so that results can always be retrieved with sub-second latency. A common use case for caching is to prepare query results that are going to be embedded into live customer-facing dashboards. This provides your customers with a lightning fast and positive user experience every time. Advanced use cases leverage pre-computed and cached results to intelligently personalize the application based on the user’s historical behavior. As a side bonus, caching queries and datasets helps save on compute query costs.

In summary, Cached Queries and Cached Datasets pre-computations do not contribute to your per-project query rate limit. This combined with subsecond response times makes them ideal for building customer-facing embedded analytics.

Saved Queries

Saved queries are a super user-friendly way to revisit your favorite metrics. Rather than entering the same query parameters over and over again, queries can be easily saved, edited, and shared with your teammates. This way everyone can keep up to date with the most important metrics.

Saved Queries are a simple way to put your metrics and charts into our hosted Dashboards application. Saved queries are fully supported by the Keen API, meaning you can access your saved queries programmatically from anything you build on top of Keen’s platform. We’ve streamlined our UI to make it easier for you to customize and revisit your queries again and again.

Cached Query

Cached Queries

Create Cached queries via the Keen API or the Explorer UI. See our detailed API reference documentation on Query Caching for details & code samples.

When you create a Cached Query, you can control the “refresh_rate”. This defines the specific interval at which you would like the query to be automatically computed on our side.

Turning a Saved Query into a Cached Query

You can create a Cached Query right from the Explorer. If you haven’t already saved your query, give it a name (ex: “Purchases this Month”) to save the query. Then, to cache your most important queries just click the “Enable Caching” checkbox and set your refresh rate.

Cached queries are automatically configured with a refresh_rate of every 4 hours, but this query computation interval can be edited to match your application’s needs, up to 48 hours. Cached Queries that refresh more frequently will generate more properties scanned.

If you own any specific project that requires Cached Queries to be updated more frequently, please reach out to us anytime!

Name Your Query to Save

To find out whether your query has successfully been cached, the Explorer will show you “Caching is enabled” and lets you know when the query was last computed. Sample:

Caching is Enabled

Retrieve a List of All Saved & Cached Queries

To get a full list of the queries you’ve saved and cached, see the API call for: Getting All Saved Query Definitions.

Ready to learn about Cached Datasets?

See our follow-up guide on caching: Cached Datasets.