NEW  New: cqlint (lint + format), cql-migrate and cqlprof → see the benchmarks

cql-ai
CQL HPC

Type safety is not enough when your tables hold billions of rows. cql-ai reads your .cql files in CI and warns when a statement is likely to be a performance bottleneck on your data: large partitions, scatter-gather, tombstones, write amplification. Trained on measured latencies, not on rules.

$ cargo install cql-ai-cli
In CI

A warning before it hurts production

$ cql-ai check queries/ --schema schema/
warning: AI predicts a large result bottleneck (100% confidence, about 40x the cost of a point read) on line 1
 --> queries/events.cql:1:1
  |
1 | SELECT * FROM events WHERE part = ?
  |
  = help: cost is dominated by the number of rows/bytes returned: add a LIMIT, page, or project fewer columns
  = note: data shape: 200 partitions x 10k rows per partition

warning: AI predicts a server scan bottleneck (100% confidence, about 22x the cost of a point read) on line 3
 --> queries/events.cql:3:1
  |
3 | SELECT count(*) FROM events WHERE part = ?

A four-statement file checks in about 0.2 s wall clock, including process start. The same query is a problem on a 10,000-row partition and fine on a 10-row one, so you tell the model about your data with one comment above the table:

-- hpc: partitions=200000 rows=10000 row_bytes=300
CREATE TABLE events (part text, clust text, data text, PRIMARY KEY ((part), clust));
What it predicts

Measured bottlenecks

LabelMeasured definition (relative to a baseline on the same table)
LargeResultread ≥ 3× a point read, returns ≥ 100 rows or 32 KiB, and LIMIT 1 removes most of the cost
ServerScanread ≥ 3× a point read but returns almost nothing (count, filtering)
FanOutread ≥ 3× a point read touching many partitions (IN, token scans, indexes)
TombstoneScan≥ 2× slower than the same statement on a clean twin table (queue pattern)
WriteCostwrite ≥ 1.8× a plain insert (batches across partitions)
LightweightTxnIF NOT EXISTS and friends pay a Paxos round trip

Plus a cost estimate: how many times a point read (or a plain insert) the statement is expected to cost. Labels come from running every training statement on a real database, with counterfactuals such as the same statement with LIMIT 1 and on a clean twin table.

Results

Better than rules, and data shape is the difference

Model trained on ScyllaDB measurements only (1,597 statements). Macro-F1 over the labels present, on data the model never saw.

Macro-F1 on unseen worlds (same workloads, other data shapes)
model + data stats
0.855
model, no stats
0.683
keyword rules
0.557
Macro-F1 on a different engine (trained on ScyllaDB, tested on Apache Cassandra 5.0)
model + data stats
0.802
model, no stats
0.624
keyword rules
0.516
Test setStatementsMacro-F1Cost error (log10)Rank correlation
unseen worlds6310.8550.1350.920
unseen workload families (YCSB, KillrVideo comments)7560.8890.1360.891
other engine (Cassandra 5.0)2,6140.8020.1790.848

A cost error of 0.135 means the predicted slowdown is typically within a factor of 1.4 of the measured one. The weak spots are WriteCost (precision 0.5–0.6) and TombstoneScan on the other engine (precision 0.48).

The data

Public workloads, measured

Workload shapeSource
key-value, tabular, IoT time seriesNoSQLBench baselines (Apache-2.0)
blog posts, counterscassandra-stress profiles from Apache Cassandra
user tableYCSB core workloads
cpu time seriesTSBS layout
commentsKillrVideo

90 worlds per engine, from 10 to 400,000 partitions and from 1 to 60,000 rows per partition, plus tombstone-heavy and indexed variants: about 2,650 measured statements each on ScyllaDB and Cassandra 5.0. Published as cql-hpc-bench.

Limits, stated plainly. All numbers come from one node in Docker on one Apple M3, so cluster effects are not in the data (ratios are relative, but another cluster can rank statements differently). A hot-key class was dropped: with all clients on one partition, throughput did not degrade on a single ScyllaDB node (ratio ≥ 0.9), so there was nothing to learn. Alternating deletes made reads faster on ScyllaDB; only the queue pattern (first 95 % of a partition deleted) shows a tombstone cost. Thresholds such as 3× are choices, documented in the repository. cql-ai does not replace cqlc check, which is exact and about 400× faster for the anti-patterns it knows; it answers a different question: how slow will this be on my data?