Analytics, Columnar & Tiering
PAX columnar scans, approximate HyperLogLog/quantile sketches, continuous aggregates, hot/cold tiering, and S3 archives.
SpydDB runs analytical aggregations, approximate streaming sketches, materialized continuous aggregates, and compressed columnar scans inside the same engine that serves OLTP transactions — zero ETL pipelines required.
Columnar & Hybrid Collections (store column for)#
Declare hot analytical fields using columnar / PAX storage so wide scans read only the touched columns and skip non-matching segments via zone maps (min/max statistics):
create collection metrics_events {
id: u64 primary auto_increment,
ts: timestamp not null,
service: string(80) not null,
region: string(24) not null,
latency_ms: f64 not null,
status: u16 not null,
metadata: json,
store column for (ts, service, region, latency_ms, status)
}Ensure optimal analytical execution in server.json:
{
"columnar_zone_maps": true,
"columnar_vectorized": true,
"max_parallelism": 0
}(max_parallelism: 0 utilizes one worker thread per available CPU core.)
Exact Aggregations & Approximate Sketches#
Exact Group-By Analytics#
metrics_events
| where ts >= "2026-11-01T00:00:00Z" and region == "us-east-1"
| group by service, status
| agg count() as requests,
min(latency_ms) as min_ms,
avg(latency_ms) as avg_ms,
max(latency_ms) as max_ms
| sort requests descBounded-Memory Approximate Sketches#
Use HyperLogLog (approx_count_distinct, ~1.6% relative standard error) and centroid quantiles (approx_percentile) for multi-million-row cardinality and tail latency queries:
metrics_events
| where ts >= $1
| group by service
| agg approx_count_distinct(user_id) as unique_users,
approx_percentile(latency_ms, 0.95) as p95_ms,
approx_percentile(latency_ms, 0.99) as p99_ms
| sort p99_ms descContinuous Aggregates & Materialized Views#
Keep expensive rollups continuously warm inside SpydDB:
create continuous agg hourly_sales from orders {
| group by hour(placed_at), region
| agg count() as order_count, sum(total) as gross_revenue
| refresh every 1m
}
-- Query the rollup directly like any collection
hourly_sales | where region == "eu-central" | sort hour desc | take 24
-- Or force an immediate manual refresh
refresh materialized view hourly_salesIncremental materialized views (incremental on <watermark_field>) maintain watermark deltas so refreshes avoid rescanning historical immutable rows:
create materialized view service_health incremental on ts as
metrics_events
| group by service
| agg count() as total, avg(latency_ms) as avg_msAutomatic Hot / Cold Storage Tiering#
SpydDB can automatically migrate aging inline rows into compressed immutable columnar segments while retaining every secondary index, encryption envelope, tenant namespace, and snapshot guarantee:
{
"tiering_interval_secs": 30,
"hot_cold_threshold_secs": 86400,
"tiering_batch_rows": 128
}- Rows older than
hot_cold_threshold_secs(24 hours default) transition transparently to compressed columnar storage. - Queries span hot and cold data in one snapshot without changing SQL or SpydQL.
Searchable S3 / Object Storage Archives#
Offload entire historical collections directly to S3-compatible object storage while keeping them queryable in place:
create archive orders_2025 from orders to "s3://analytics-archive/spyddb/orders-2025"
-- Query archived historical rows directly under normal RBAC & filters
orders_2025 | where status == "paid" | agg count() as total_orders, sum(total) as total_revArchives verify SHA-256 content digests and preserve exact types (u64, decimal, timestamp, uuid) even after the source collection is truncated or dropped.