# Iterative-scan benchmark, case C1: 1% correlated CROSS-TENANT key + a residual predicate.
# RUN 2026-10-07 (55 min on a release Postgres; analysis in REPORT-residual-filter.md). Needs a pg_pinecone build with iterative scan + deepen-before-widen;
# see configs/README-residual.md for setup and the run command.
#
# Shape (the 2026-09 "wiki_dpr 1% correlated cross-tenant -- C1/C3" cells): wiki_dpr 1M x 768d, same
# artifact/seed/k-means as configs/wikidpr_1m_pg_pinecone.yaml (so its k-means and ground-truth
# caches are reused if datasets_cache is shared). The pg_pinecone index is built on
# (embedding, filt_correlated_0010_eq): that column is the PUSHED key. The residual is a second
# column the index cannot push (filt_uncorrelated_0003_eq / _0010_eq, i.e. `category = X` with a
# 0.3% / 1% pass rate, independent of the tenant key): the planner leaves it as an executor
# Filter, so the scan can return fewer than LIMIT 10 unless it iterates.
#   combined: 33 rows (1% key x 0.3%) and 113 rows (1% key x 1%) of 1M.
# Queries are the out_region (cross-tenant) pool only.
#
# Sweep (full factorial per filter cell, 1 and 8 clients):
#   pg_pinecone: pinecone.iterative_scan {off, relaxed_order, strict_order}
#             x pinecone.max_scan_tuples {2000, 20000, 100000}   (not applied when off)
#             x pinecone.rescore_multiplier {10, 50} x pinecone.scan_fraction {0 = auto ramp, 0.5}
#   pgvector: hnsw.iterative_scan {off, relaxed_order, strict_order} x hnsw.ef_search {40, 200}
#             x hnsw.max_scan_tuples {20000 (default), 100000} (not applied when off)
# Recorded per point: recall@10, rows returned at LIMIT 10 (mean, frac filled), p50/p95/p99,
# qps, pinecone.last_scan_stats() (batches, rescored mean/p95, capped fraction).
#
# mode_l_threshold 0.005 keeps the 1% key in mode H (IVF + in-loop key filter) as the 2026-09
# C1 cells did; at the shipping default (0.03) a 1% key routes to mode L (exact over the key's
# rows), where the iterative GUCs do nothing. Add a system without it to measure that routing.
name: residual_c1
seed: 42
k: 10
warmup_queries: 20
hardness_recall_threshold: 0.97
min_throughput_seconds: 5.0

postgres:
  maintenance_work_mem: 8GB
  min_wal_size: 1GB
  max_wal_size: 4GB

dataset:
  kind: real
  artifact: wikidpr_768d_1m.npz
  n: 1000000
  dim: 768
  n_centers: 1000
  kmeans_sample: 100000
  kmeans_iters: 15
  n_queries: 500

metric: l2

filters:
  query_modes: [out_region]
  run:
    - {selectivity: 0.01, mode: correlated, residual: {selectivity: 0.003, mode: uncorrelated}}
    - {selectivity: 0.01, mode: correlated, residual: {selectivity: 0.01, mode: uncorrelated}}

systems:
  - name: pgvector_hnsw
    type: hnsw
    skip_unfiltered: true
    explain_probe: true
    build_params: {m: 16, ef_construction: 64}
    sweep_param: ef_search
    sweep_values: [40, 200]
    iterative_scan_values: ["off", "relaxed_order", "strict_order"]
    scan_budget_param: hnsw.max_scan_tuples
    filtered_scan_budget_values: [20000, 100000]

  - name: pg_pinecone_native
    type: pg_pinecone_native
    skip_unfiltered: true
    explain_probe: true
    record_scan_stats: true
    build_params: {seed: 42, mode_l_threshold: 0.005, filter_column: filt_correlated_0010_eq}
    sweep_param: rescore_multiplier
    sweep_values: [10, 50]
    iterative_scan_values: ["off", "relaxed_order", "strict_order"]
    scan_budget_param: pinecone.max_scan_tuples
    filtered_scan_budget_values: [2000, 20000, 100000]
    scan_fraction_values: [0.0, 0.5]

  # Exact reference (forced seqscan + top-N sort, recall 1.0 by construction): what an index has to beat.
  - name: exact_seqscan
    type: exact
    skip_unfiltered: true
    sweep_param: none
    sweep_values: [0]

concurrency: [1, 8]

churn:
  enabled: false

sift1m:
  enabled: false
