Skip to main content

Module tempstore

Module tempstore 

Source
Expand description

v7.39 (round 786, T35 Phase A) — host-provided temporary storage for query-time spilling.

The engine is no_std: it cannot open a file. Every other host capability it needs — the wall clock, backend signalling, timezone lookups — arrives as an injected fn pointer, and spill storage follows the same shape.

Why it exists: a large ORDER BY is materialised whole today. With SPG_MAX_QUERY_BYTES set the query DIES at the ceiling (QueryBytesExceeded); with the budget off, resident memory grows with the input — round 785 measured a 60 MB sort taking 240 MB of RSS, while PG18 answered the same query under a 4 MB work_mem with Sort Method: external merge Disk: 61072kB. Both of SPG’s outcomes break its own rules (never-die; resident memory must not grow linearly), and the capability gap is not speed — it is whether the query can finish at all.

This module is the seam only. Run generation and the k-way merge land in Phase B/C; with no factory injected the engine behaves exactly as it does today, byte for byte.

Structs§

SpillStats
v7.37 (round 884) — what a spill actually cost, for pg_stat_database.temp_files / temp_bytes and for EXPLAIN ANALYZE’s Sort Method.

Enums§

TempStoreError
Why a spill operation could not proceed. The host maps its own I/O errors into Io; the engine only ever reports them upward.

Traits§

TempRun
One spill run: written once in sorted order, then read back once in that same order by a merge cursor.

Type Aliases§

TempRunFactory
Host factory: hand back a fresh, empty run.