Retention¶
pghf.purge_results_before(p_before timestamptz, p_dry_run boolean DEFAULT false)¶
Deletes every run older than the cutoff you supply — everything that belongs to those runs (raw results, run configuration, evaluations) is deleted automatically along with them — and reports how many rows were (or, for a dry run, would be) removed from each. Nothing in this framework purges automatically; call this yourself, or from your own scheduler. Catalog data is never in scope — only execution history. Deliberately not SECURITY DEFINER — the caller needs their own delete permission on the runs table for a real, non-dry-run purge.
| Parameter | Type | Mandatory | Default | Description |
|---|---|---|---|---|
p_before |
timestamptz |
Yes | — | Cutoff — required, so an accidental unbounded purge can't happen silently. To purge everything, pass an explicit far-future timestamp (for example, 100 years from now) — there is no separate "purge all" entry point. |
p_dry_run |
boolean |
No | false |
true runs the exact same counting logic without deleting anything — the preview is exact, not an estimate. |
Returns: a result set reporting whether it was a dry run, the cutoff used, and how many rows were removed (or would be) from each of the four affected tables.
pghf.purge_results_before_batched(p_before timestamptz, p_batch_size integer DEFAULT 10000, p_dry_run boolean DEFAULT false)¶
A batched version of pghf.purge_results_before(): deletes in batches of the given size, committing after each one — useful for a large first-ever purge against long-unpurged history, where deleting everything in one statement would mean one very long-running transaction (heavy write-ahead log generation, a lock held for the entire duration, and a large amount of cleanup work left behind afterwards). This is a procedure, not a function, specifically so it can commit between batches. Progress is reported as it goes, not as a single return value.
| Parameter | Type | Mandatory | Default | Description |
|---|---|---|---|---|
p_before |
timestamptz |
Yes | — | Cutoff — the same "required, no implicit purge-everything" rule as pghf.purge_results_before(). |
p_batch_size |
integer |
No | 10000 |
Rows deleted (and committed) per batch. Must be a positive number. |
p_dry_run |
boolean |
No | false |
true reports the total count that would be deleted, in one message, without deleting or looping. |
Returns: nothing directly (progress is reported as the batches run). This is a procedure, and must be invoked as a standalone CALL statement because it commits internally. Not restricted to a specific role by default, the same as pghf.purge_results_before() — a real, non-dry-run purge still needs the caller's own delete permission on the runs table.
Continue to Catalog Seeding.
pghf.purge_notification_log_before(p_before timestamptz, p_dry_run boolean DEFAULT false)¶
Prunes the notification outbox (pghf.notification_log). The outbox is deliberately untouched by the run purges above — its rows outlive the runs and evaluations they fired from, so "did we notify on this?" stays answerable — which also means it grows until you prune it with this.
| Parameter | Type | Mandatory | Default | Description |
|---|---|---|---|---|
p_before |
timestamptz |
Yes | — | Delete outbox rows fired before this instant. |
p_dry_run |
boolean |
No | false |
true counts what would be deleted without deleting anything. |
Returns: one row with the affected count. Same operator model as the run purges: your own role's SELECT/DELETE rights on the outbox are what's checked. Still-'pending' rows past the cutoff are deleted like any other — an undelivered firing older than your retention window is a delivery problem to fix, not a row to keep forever.