Count
count.co
  • Getting Started
    • What is Count?
    • Count FAQ
    • Intro to your workspace
    • Example canvases
    • Getting started guides
      • Set up your workspace and projects
        • 1. Review workspace settings
        • 2. Create and organise your projects
      • Canvas orientation
      • Your first ad hoc analysis
        • 1. Examples and templates
        • 2. Build your first queries
        • 3. Create visuals
        • 4. Caching, local cells and scheduling
        • 5. Collaborating with a stakeholder
      • Your first report
        • 1. Examples and templates
        • 2. Filters and control cells
        • 3. Sharing your report
        • 4. Alerts
  • Connect your data
    • Database connection overview
      • Athena
      • Azure Synapse
      • BigQuery
      • Databricks
      • Microsoft SQL Server
      • MySQL
      • PostgreSQL
      • Redshift
      • Snowflake
    • Refresh database schema
    • Upload CSV files
    • dbt integration
      • ☁️dbt Cloud integration
      • 👩‍💻dbt Core integration
  • Import & Export
    • Import from other tools
      • Import Miro files
      • Import SQL files
      • Import Google Sheets
      • Import Jupyter notebooks
    • Export code and results
      • Export compiled SQL and Jinja-SQL
      • Export CSV files
      • Export images and PDF files
  • THE CANVAS
    • Navigating the canvas
      • Canvas tool bar
      • Data sidebar
      • Customizing the canvas
    • Canvas objects
      • Cells
      • Text and markdown
      • Shapes and tools
      • Sticky notes
      • Frames
      • Images
      • Embeds
      • Stamps
      • Grouping objects
      • Object order and alignment
      • Locking objects
      • Scaling objects
      • Shared styles
    • Overviews
    • Templates
    • Count AI
    • Alerts and subscriptions
      • Slack integration
    • Keyboard shortcuts
  • Querying data
    • Cells overview
      • Dynamic query compilation engine
    • SQL cells
      • Referencing other cells
      • Jinja templating
      • SQL formatting
    • Python cells
    • Visual and low-code cells
      • Calculations in visuals and low-code cells
      • Joins in visuals and low-code cells
    • Control cells
      • Single and multiple selects
      • Date controls
      • Text, number, and boolean controls
      • Custom control cells
    • Local DuckDB cells
      • DuckDB on the server
    • Query caching and scheduling
    • Manage queries and results
    • Troubleshooting
  • Visualizing data
    • Visualization overview
    • Templated visuals
    • Custom visuals
      • Marks
      • Facet
      • Subplots
      • Style
      • Filters
    • Formatting a visual
      • Axes
        • Secondary Axis
      • Colors and labels
      • Legends
      • Tooltips
    • Column summaries
    • Dynamic text
    • Every Visual Under the Sun
  • Presenting and Reporting
    • Reports and Slides
  • Count Metrics
    • Intro to Count Metrics
    • Build and edit a catalog
    • Views
      • Creating views
      • Customizing views
    • Datasets
      • Creating datasets
    • Save changes to the catalog
      • Catalog validation
      • Version control
    • Exposing catalogs to the workspace
    • Caching in Count Metrics
    • Using the catalog
      • Explore from cell
  • Sharing and Permissions
    • Real-time collaboration
    • Comments
    • Sharing permissions
    • Shared links
    • Embedding canvases
  • History and Versions
    • Version control
    • Duplicating and merging
    • Data snapshots
  • Settings and administration
    • Workspace settings
      • Workspace members
      • Groups
      • Tags
      • Billing
      • Single sign-on (SSO)
        • Okta
        • Entra ID
        • JumpCloud
        • Google
        • Generic OIDC
      • Brand
    • Connection settings
    • Project settings
    • User settings
    • Roles and permissions
  • Quick guides
    • Interactive control guides
      • Date ranges
      • Date groupings
      • Search
      • Select All
  • Resources
    • Join the Slack community
  • Blog
  • Security overview
  • Terms of use
  • Pricing FAQ
Powered by GitBook
On this page
  • Enabling caching per-view
  • Caching configuration options
  • YAML caching example
  • DuckDB on the server
  1. Count Metrics

Caching in Count Metrics

Speed up user experience and drive down compute costs with catalog-level caching.

PreviousExposing catalogs to the workspaceNextUsing the catalog

Last updated 1 month ago

Caching in Count Metrics is available at the workspace level, enabling query results to be stored and reused across multiple canvases. This reduces database query load, improves performance, and ensures faster data retrieval.

Enabling caching per-view

To enable caching, configure caching settings within each view by:

  • Updating the connection to null

  • Referencing the database table in the dependencies section

The schema panel on the right-hand side provides details on available caching options, allowing for flexible control over query execution and data freshness.

Caching configuration options

  • caching – defines caching settings for source dependencies attached to a connection.

  • caching.duration – specifies how long source dependency results are cached (in seconds).

  • caching.schedule – a cron expression that defines the refresh schedule for cached data. This value may need to be enclosed in single quotation marks. (Optional)

Refer to the example below for implementation details. Proper caching configuration ensures efficient query execution while maintaining data accuracy and consistency.

YAML caching example

caching:
  duration: 360000
  schedule: 0 0 * * *    

source:
  connection: null
  query: SELECT * FROM events_df
  dependencies:
    - name: events_df
      query: SELECT * FROM `count-data`.demo_data.events
      connection: 7zoODN2N9UI

DuckDB on the server

When your views contain local queries (i.e. with connection: null) , Count will decide how to execute these queries automatically, either in DuckDB on the server or in your browser (just like other cells in the canvas).

Let's suppose someone opens a canvas with a visual that references a view containing local queries. The following steps will occur:

Step 1

First, the non-DuckDB queries for the view are executed, and the results are returned to your browser. (If caching is enabled for the view, then cached results may be returned.) Only the first 10,000 rows of results are returned.

Note - when running view queries on your database, they will have no row limit applied. If you would like to reduce the amount of data these queries return, add an explicit limit to the SQL definition in the view.

Step 2

Based on the results from step 1, Count decides how to execute the rest of the queries for the view.

Queries are executed on the server if:

  • Any non-DuckDB queries returned more than 10,000 rows

  • Your local DuckDB database is nearing its memory limit

Queries are executed in your browser if:

  • All non-DuckDB queries returned fewer than 10,000 rows

  • Your view includes Python dependencies

  • You have not enabled caching for this view

Step 3

Now that all of the view queries have been completed, the visual cell in the canvas will be executed. Count will apply the same logic to decide whether to execute the visual in your browser or on the server. Either way, it will not send a new query to your database if the view is using local queries.

Finally, suppose the visual is edited and a new query needs to be run. Rather than running steps 1 and 2 again, Count will re-use the results for any referenced views and only run the queries for the visual in step 3.

No Caching Enabled
With caching enabled