-- record random i/v pairs for size n
\set seed random(1, 1000000000000000000)
\set n 128
\set i random(0, :n-1)
\set v pr_perm(:i, :n, :random_seed + :seed)
INSERT INTO perm_vals AS pv (i, v, cnt) VALUES (:i, :v, 1)
  ON CONFLICT (i, v) DO
    UPDATE SET cnt = pv.cnt + 1;
