# v0.16.0 — Fast-Path Strategies, Auto-Indexing, and Benchmark Regression CI

> **Full technical details:** [v0.16.0.md-full.md](v0.16.0.md-full.md)

**Status: ✅ Released** | **Scope: Medium** (~4–5 weeks)

> An append-only fast path for insert-only sources, an algebraic aggregate
> shortcut that eliminates redundant table scans, automatic index creation
> for stream tables, a shared-memory template cache, and automated
> benchmark regression detection in CI.

---

## What problem does this solve?

Many data sources are append-only — logs, events, measurements — where rows
are only ever inserted, never updated or deleted. The full differential engine
overhead was unnecessary for these cases. Complex aggregates were still
rescanning unchanged rows due to internal structure. Stream tables lacked
automatic indexes, leading to slow queries on large outputs. And performance
regressions in the differential engine were sometimes not noticed until users
reported them.

---

## Append-Only Fast Path

For source tables where only INSERT operations occur (no UPDATE or DELETE),
the differential engine can take a dramatically simpler path: the delta is
always additive. There is no need to compute what was removed.

The append-only bypass detects this case automatically (or can be hinted
explicitly with `append_only => true`) and uses a highly optimised execution
path that is typically 3–5× faster than the general differential path for
the same query.

*In plain terms:* if you are building stream tables over event logs or sensor
readings that only grow, the refresh will be significantly faster without any
query changes.

---

## Algebraic Aggregate Fast-Path

The general differential aggregate path maintains a running aggregate by
applying delta rows to a stored partial state. For complex multi-group
aggregates, this involved a join back to the current stream table state on
every refresh.

The algebraic fast-path eliminates this join for a broad class of aggregates
(SUM, COUNT, AVG, and combinations), using the already-maintained partial
state without any re-join. This reduces the number of table scans per refresh
significantly.

---

## Auto-Indexing

Stream tables now automatically receive indexes on their most common access
patterns:

- The primary key (used for the MERGE upsert during differential refresh)
- Columns used in the defining query's GROUP BY or ORDER BY
- Foreign key columns that appear in downstream stream table JOINs

An `AUTO_INDEX` setting can disable this if you prefer manual index management.

*In plain terms:* queries against stream tables are now automatically fast
without requiring manual `CREATE INDEX` commands.

---

## Shared-Memory Template Cache

The differential engine generates SQL templates for each stream table's
refresh logic. Previously, each backend process compiled these templates
independently. The shared-memory template cache stores compiled templates
in shared memory, so all backend processes benefit from the first
compilation.

This is especially impactful for deployments using connection poolers (like
PgBouncer) where many short-lived connections each previously paid the
compilation cost independently.

---

## Benchmark Regression CI

A new CI job runs the core differential engine micro-benchmarks on every
pull request and compares the results against the baseline from the most
recent push to `main`. A pull request that regresses any benchmark by more
than 20% fails CI, preventing performance regressions from being merged
silently.

---

## Scope

v0.16.0 delivers meaningful performance improvements for the most common
deployment patterns (append-only sources, large aggregate queries, pooled
connections) and closes the regression visibility gap with automated
benchmark CI. The auto-indexing feature removes a common source of confusion
for new users.
