Skip to main content

Replay simulator

The replay simulator answers "what would chukei have saved us last month?" offline — no proxy in the path, no client changes, just a CSV export of your query history.

1. Export QUERY_HISTORY

COPY INTO @my_stage/queries.csv FROM (
SELECT query_id, query_text, warehouse_name, start_time, end_time,
total_elapsed_time, user_name, query_tag
FROM SNOWFLAKE.ACCOUNT_USAGE.QUERY_HISTORY
WHERE start_time >= DATEADD(day, -30, CURRENT_TIMESTAMP())
) FILE_FORMAT = (TYPE = CSV HEADER = TRUE)

2. Replay

chukei replay --query-history queries.csv --output projection.json

The simulator sorts by start_time, runs each query through the same SQL fingerprinting and rewrite analysis as the live proxy, and reports projected savings per lever (cache, router candidates, suspend, rewrite counts). It does not model in-flight coalescing because QUERY_HISTORY does not contain concurrent request timing at the proxy layer.

3. Signed projection

chukei replay --query-history queries.csv --output projection.json --evidence

Produces an Ed25519-signed bundle pinning the input corpus hash — the projection can be verified by anyone with chukei evidence verify.

Methodology

Replay is a projection, not the realized-savings ledger. Cache and router savings are priced from each query's measured elapsed time and warehouse size; rewrites are counted but not priced; suspend uses the idle-gap model shown in the JSON report. Real deployments should be reconciled against WAREHOUSE_METERING_HISTORY.