Waystone
For a query shape the administrator selects (WAYSTONE ON <select>), Waystone records the position (trail) where the previous execution found a row by tuple key, for the same literal values (instance) of the same shape, and reads from that position on the next execution. If the trail is wrong or missing, the engine simply descends the tree as usual, so the result never changes. Shapes that are not selected record nothing.
Key Specs
| Item | Value |
|---|---|
| Enable | WAYSTONE ON <select>: does not execute the statement, only records the shape (fetch_id). Literal values do not matter |
| Disable | WAYSTONE OFF <select> or WAYSTONE OFF <fetch_id> |
| Privilege | admin, outside a transaction |
| Target | Only basic-syntax SELECT with a tuple-key equality (=). Query-layer statements, WITH, and DML are rejected |
| Record and replay | Records on the 2nd execution of the same instance, replays from the 3rd. A restart erases all trails and keeps only the selection (opt-in) |
| Cost | One memory read per SELECT when no shape is selected |
| Check | SHOW PATTERNS (sys.patterns), fetch_id= in ANALYZE, replays=<n> on replayed steps |
When It Pays Off
Engine's own measurements (v3.3.0-97, 1 core):
| Statement shape | Result |
|---|---|
| Probing another table by tuple key for each row of a filter scan (200 probes per statement) | Throughput +5.7%, server CPU −7.2% |
| Single-row lookup, short tuple-key join | No gain. Recording costs 2.7 to 3.9% of server CPU |
So the manual recommends choosing statements where ANALYZE shows many probe rows after a scan step, and leaving single-row lookups alone.
Statement Shape and fetch_id
fetch_id is the statement shape with the select list removed and every literal replaced by a marker. So if SELECT a … and SELECT COUNT(*) … have the same FROM … WHERE, they have the same shape and share trails. The name does not contain the namespace or the table, so ON records the table the example refers to alongside it. The same statement under a different USE is a different target. DROP TABLE ends the selections attached to that table.
Comparison with Other DBMSs
No other DBMS has exactly the same feature as Waystone. The closest are Oracle's approach of an application holding a ROWID and reusing it, which caches a position rather than a result, and InnoDB's Adaptive Hash Index (remembers the leaf position of frequently searched keys with a hash). The difference is that Waystone works only on shapes the administrator selects and guarantees the result even when the trail is wrong.