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
  • How does the dynamic query compilation engine work?
  • How does query compilation work for local cells?
  • What are the benefits of dynamic query compilation?
  • When are cells executed?
  1. Querying data
  2. Cells overview

Dynamic query compilation engine

Literally magic.

PreviousCells overviewNextSQL cells

Last updated 15 days ago

Count features a unique dynamic query compilation engine that enables unmatched flexibility in how you write and interact with SQL and no-code cells in the canvas. It is designed to harness the speed of modern cloud data warehouses while minimizing data movement and keeping your data secure.

How does the dynamic query compilation engine work?

At query runtime, Count dynamically compiles the SQL for each cell and sends it to the appropriate database, then renders the result. When two or more cells are joined together in the DAG, Count will include all SQL necessary to execute each cell - including the SQL from any parent cells. For example:

  • Cells a and b are SQL cells, cell b contains the SQL select * from a.

  • At runtime, Count sends the SQL for cell a to the database as-is (potentially adding a limit).

  • At runtime, Count generates the SQL for cell b which looks like with a as (<query for a>), select * from a

Because the query for each cell contains all of the necessary SQL, all queries can be executed in parallel. Due to this fact, it is common to see the results of some cells appear before their parents have finished executing, particularly if the results for the parent cell are larger.

Remember, each cell is a compilation of CTEs - you can see the at any time and export it to your database.

How does query compilation work for local cells?

For any in your DAG, query compilation and execution behaves slightly differently:

  • If a local cell references a parent cell from a data warehouse, the SQL for the parent cell is not compiled into the local cell. Rather, the parent cell is treated as if it is an external database table.

  • Local cells have to wait until their parent cells have finished executing before they can be executed, as local cells operate on cell results.

What are the benefits of dynamic query compilation?

By compiling SQL dynamically at runtime and relying on your underlying database for computation, Count enables the following:

  • Reusability - define a metric in one cell, then query that cell in downstream analysis.

  • Reactivity - changes flow through the DAG and cause downstream cells to update automatically.

  • Auto-lineage - Count builds the DAG for you by checking which tables you reference in your cells.

  • Control over data locality - you don't need to pull all of your database results into the canvas to benefit from cell referencing.

  • Performance - Count takes full advantage of the capabilities of your cloud data warehouse for scalability and query speed.

  • Write in native SQL - whatever your database, you can use your native SQL syntax to work in Count rather than learning a tool specific query language.

When are cells executed?

Cells are executed in response to several events. Here 'cell' could mean a SQL cell, visual cell, control cell etc.

  • A canvas is opened, and the cell is visible or referenced by a visible cell.

  • A report is opened, and the cell is in one of the report frames or referenced by one that is.

  • The input for a cell is edited.

  • The input of a parent of a cell is edited (this means that editing a single cell can cause multiple cells to execute).

  • A cell is duplicated or pasted into the canvas.

  • A new reference in a local cell is created to a cell that has not previously executed.

  • A new dynamic text reference is created to a cell that has not previously executed.

  • A frame is unhidden, and contains cells which have not previously executed.

  • The view is switched from a report to a canvas, which contains cells that have not previously executed.

To disable automatic execution of cells that run on your data warehouse, select this option in the or in the canvas .

compiled SQL
local cells
workspace settings
query execution menu