Caching & performance

How Flax keeps queries fast — connection pooling, a per-tenant result cache, and the tiered source cache, plus when a query hits cache versus your warehouse.

Dashboards and explorations issue the same or overlapping queries repeatedly. Flax avoids paying warehouse latency and compute for every view by pooling connections and caching results (ADR-0029, ADR-0008), while never serving data past its freshness policy.

#Connection pooling

Flax keeps a bounded, reusable connection pool per warehouse connection rather than dialing a fresh connection for every query. A global cap with LRU eviction stops any one tenant from exhausting resources, and a pool is dropped automatically when its connection details change, so rotated credentials never leave a stale pool behind.

#Result cache

Each query result is cached per tenant with a time-to-live (TTL). The cache key is derived from the organization, connection, compiled SQL, and its arguments, so an identical repeat query is served from cache and a genuinely different query is not.

Behaviour Detail
Scope Per tenant (organization) — never shared across organizations.
Key Hash of org, connection, SQL, and args.
Freshness Governed by a TTL; a short default keeps results current.
Bypass An explicit refresh re-runs the query against the warehouse.

#Tiered source cache

The result cache is the first tier of a broader tiered cache for customer source data (ADR-0008). A larger materialized tier for reusing pulled data across overlapping queries is planned; today the per-tenant result cache captures most of the repeat-query win.

#Cache vs. warehouse

  • Cache — a repeat query whose key matches a fresh (within-TTL) cached result is served without touching the warehouse.
  • Warehouse — a first-time query, a query past its TTL, or an explicit refresh is compiled and pushed down to your warehouse (ADR-0004), and the fresh result repopulates the cache.

Note

Because a cached result can lag the source until its TTL expires, use refresh when you need to confirm the latest data.