diff --git a/src/core/quote-lifecycle-retention.mjs b/src/core/quote-lifecycle-retention.mjs index 926b1c8..117c429 100644 --- a/src/core/quote-lifecycle-retention.mjs +++ b/src/core/quote-lifecycle-retention.mjs @@ -42,10 +42,10 @@ export const DEFAULT_QUOTE_LIFECYCLE_RETENTION_POLICY = Object.freeze({ rollup_retention_ms: 90 * 24 * 60 * 60 * 1000, rollup_stale_after_ms: 15 * 60 * 1000, preserve_successful_evidence: true, - max_delete_rows_per_pass: 100_000, + max_delete_rows_per_pass: 2_000_000, pressure_table_bytes: 1_500_000_000, pressure_database_bytes: 3_500_000_000, - config_version: 1, + config_version: 2, }); export function isSuccessfulQuoteOutcome(row = {}) { diff --git a/src/lib/postgres.mjs b/src/lib/postgres.mjs index 403bb71..55b896c 100644 --- a/src/lib/postgres.mjs +++ b/src/lib/postgres.mjs @@ -137,6 +137,10 @@ export async function ensureHistorySchema(pool) { CREATE INDEX IF NOT EXISTS ${table}_ingested_at_idx ON ${table} (ingested_at DESC) `); + await pool.query(` + CREATE INDEX IF NOT EXISTS ${table}_coalesced_at_idx + ON ${table} (COALESCE(observed_at, ingested_at) DESC) + `); } await ensureExpressionIndex(pool, { @@ -144,6 +148,11 @@ export async function ensureHistorySchema(pool) { table: 'funding_observations', expression: "(payload->>'tx_hash')", }); + await ensureExpressionIndex(pool, { + name: 'trade_execution_results_status_idx', + table: 'trade_execution_results', + expression: "(payload->>'status')", + }); await ensureExpressionIndex(pool, { name: 'funding_observations_handle_idx', table: 'funding_observations',