Canonical: https://solanashreds.xyz/blog/200ms-slots-and-your-database

# Five slots a second: designing writes that keep pace

Shorter slots doubled the rate at which a per-slot writer has to commit. Here is how to choose between batching by slot and batching by time, and how to size the write path on your own hardware.

With 200ms slots, a database that commits once per slot has to finish five commits every second, and a slot can reopen when a late shred arrives. For most pipelines, batch by time with a window spanning several slots, and make every write an upsert keyed on signature, so a reopened slot rewrites rows instead of duplicating them.

## What shorter slots change for the writer

Under SIMD-0525, Solana halved its slot target in stages, from 400 ms per slot down to 200 ms. The final step took effect at slot 454,896,000 on 9 October 2026. The number of ticks per slot, the four-slot leader window and the 432,000-slot epoch all stayed the same, so the chain's structure is unchanged; it simply produces slots twice as often.

For a decoder that writes to a database, that has one direct effect. Any design that does a fixed amount of work per slot, such as opening a transaction, writing the slot's rows, updating a "last slot" marker and committing, now does that work twice as often for the same user activity. A design that was comfortable at 400 ms can start to queue at 200 ms without anything else in the pipeline changing.

The leader window is now 800 ms (four slots of 200 ms). If your code groups work by leader, the groups arrive twice as often as before too.

## Batch by slot or by time window

Neither choice is wrong. They fail in different ways.

| Question | Batch by slot | Batch by time window |
|---|---|---|
| Commits per second | Follows the slot rate, five per second at the target | Fixed by you, for example one per second |
| Rows per commit | Varies with each slot's activity, including empty slots | Smooths out busy and quiet slots |
| Reading a slot as a unit | Easy: a slot is all or nothing in the database | Needs a slot column and a query per slot |
| Late or reopened slots | Rewrites a whole slot batch | A late row joins whichever window is open |
| Visible delay before a row lands | About one slot | Up to one window |
| Best fit | Small, slot-oriented stores; tools that show "the latest slot" | Analytics stores, high insert volumes, ClickHouse style engines |

If your readers need rows within the slot they belong to, batch by slot and make each commit cheap. If they read aggregates, or your store prefers large inserts, batch by time.

## Transactions, upserts and lock contention

Per-slot commits are short, but they are frequent, and they tend to touch the same small set of rows: the "last processed slot" marker, per-program counters and per-wallet balances. At five commits a second those hot rows become the bottleneck before the bulk inserts do.

Three habits keep contention down:

- **Move hot counters out of the write path.** Derive aggregates from the raw rows in a separate job instead of incrementing a counter row in every commit.
- **Upsert on a stable key.** Key transaction rows on the first signature, and instruction rows on signature plus instruction index. In PostgreSQL, `INSERT ... ON CONFLICT (signature) DO UPDATE` lets a repeated write update a row instead of failing; in ClickHouse, a ReplacingMergeTree table collapses rows with the same ORDER BY key inside one partition during background merges, keeping the highest version, so queries read with FINAL to see one row per key.
- **Keep the status change separate.** Insert rows as provisional and update their status in a second, batched pass after you reconcile them. Mixing both into one transaction makes every commit wait on the slowest part.

## When a late shred reopens a slot

A decoder can only emit the transactions it has recovered. If a shred for slot N arrives after you have written slot N, or recovery succeeds only once more coding shreds arrive, the decoder finds new transactions for a slot it already wrote. With per-slot commits that looks like a second batch for the same slot; with time windows it looks like a slot whose rows arrived in two windows.

Both are fine if writes are idempotent. Neither is fine if the second write inserts duplicates or overwrites the first batch wholesale. Decide in advance that a slot is never "closed" in the database by the decoder alone; it becomes closed when reconciliation confirms it.

## Back pressure from the database to the decoder

UDP has no flow control. If the database slows down and the decoder waits on it, the receiver's socket buffer fills and the kernel drops packets, which you then see as missing shreds. Put a bounded queue between decoding and writing, and decide what happens when it is full:

- write to a local file and replay it later,
- drop the oldest unwritten batch and record the gap, or
- pause decoding for lower priority programs until the queue drains.

Whichever you choose, export the queue depth as a metric. A queue that grows slowly during busy periods is your earliest warning that the write path no longer keeps up with 200 ms slots.

## A sizing method you can run yourself

We publish no throughput figures, because they depend on your schema, your hardware and the programs you decode. This method gives you your own.

1. Record a capture of raw traffic for a busy hour, so you can replay it at will.
2. Run your decoder over the capture with the database writer replaced by a counter. Note rows produced per second at the busiest minute.
3. Turn the writer back on with your chosen batching rule and replay the same capture faster than real time, at two and then four times the speed.
4. Watch the queue depth between decoder and writer. The highest replay speed at which it stays flat is your headroom.
5. Repeat after each schema change, because new indexes and new columns change the result more than anything else.

## Where this advice stops

This post is about writing decoded rows, not about receiving packets or keeping a socket fed. It also says nothing about how quickly rows become trustworthy: a row written within one slot is still provisional, and its status depends on confirmation that arrives later. If your workload needs execution results such as balances or logs on every row, raw shreds cannot provide them and no batching rule changes that.

## Next steps

The storage guides show these patterns in full: [Postgres storage](https://solanashreds.xyz/docs/pipeline/postgres) for row-level upserts, and [ClickHouse inserts](https://solanashreds.xyz/docs/pipeline/clickhouse) for large time-window batches. If you are still choosing a store, [ClickHouse or Postgres](https://solanashreds.xyz/compare/clickhouse-vs-postgres-for-solana) compares them for this exact pattern, and [idempotent writes](https://solanashreds.xyz/blog/idempotent-writes-for-chain-data) explains the keys. To watch for a growing write queue, see [monitoring decoder lag](https://solanashreds.xyz/blog/observability-for-decoders). The [slot numbering page](https://solanashreds.xyz/learn/slot-vs-block-height) explains which slot field to batch on, and the [quickstart](https://solanashreds.xyz/docs/quickstart) gets live slots into your writer.

The other change that reshaped block contents is covered in [votes left the block](https://solanashreds.xyz/blog/votes-left-the-block).
