PostHog computes warehouse suggestions every day from how the project reads its views and tables.
Each suggestion is about one view or table.
Its payload holds everything that accepting it would create or change.
1. Find the suggestions
Call warehouse-suggestions-list with status=proposed.
The results come in priority order, so start at the top.
If the list is empty, call warehouse-suggestions-status: it says whether suggestions are turned off, still collecting read history, or not eligible.
Call warehouse-suggestions-get for a suggestion the user wants to discuss.
Its evidence has the read counts behind it.
2. Explain it with its own numbers
Tell the user what accepting does and what it costs, using the payload fields. Do not invent a score or a confidence level.
- materialize: the view is read often enough that storing its result saves compute.
saves_seconds_per_monthandsaves_bytes_per_monthare what the reads stop costing.- Materializing adds a recurring refresh cost, which these numbers already subtract.
freshness_today_secondsandfreshness_after_secondssay how old the data can be now and after.refresh_interval_secondsis the proposed interval.refresh_interval_basissays what kept it from being shorter:source_sync(the sources sync no faster),fastest_schedule(PostHog refreshes views no more often),read_rate(people read the view no more often) orsavings(a shorter interval costs more than it saves).refresh_modeisincrementalwhen each refresh can read only new rows, byincremental_key, and update rows byunique_key. Otherwise it isfull, and each refresh rebuilds the whole table.
- certify: many people read this view or table, from several places. Use the read counts in
evidence. - deprecate: nobody reads this materialized view, but it still refreshes.
refresh_seconds_per_monthandrefresh_bytes_per_monthare that cost. Accepting only marks it deprecated in the data catalog. To stop the cost, offerview-unmaterializeas well.
3. Change a materialize suggestion before accepting
The payload is a starting point. To change it, pass the payload field with the same name to the accept tool. An omitted field keeps the suggested value.
- Another interval: pass
refresh_interval_seconds. - Full instead of incremental, or the reverse: pass
refresh_mode. - Other keys:
- Read the view's query with
view-get. - Call
view-check-incrementalwith that query, plus theincremental_keyandunique_keythe user wants. Without keys it listskey_candidatesandunique_key_candidates. - Accept with those keys only when the check returns
eligible: true. Otherwise explain theblockersto the user.
- Read the view's query with
- Late rows: pass
lookback_secondsso each refresh reads that far back again.
PostHog proposes incremental only when it is certain of the keys.
A full suggestion can still refresh incrementally if the user chooses keys that pass the check.
The unique key must include every column the query groups by.
4. Accept or dismiss
Accept with warehouse-suggestions-accept-prepare, then warehouse-suggestions-accept-execute after the user types confirm.
The server checks every choice against the view's current query:
- A 400 names the field it refused and why. Show the reason to the user and ask what to change.
- A 409 means the view changed after the suggestion was made, so the suggested keys no longer apply. Offer a full refresh, or keys checked with
view-check-incremental.
Dismiss with warehouse-suggestions-dismiss and a reason (not_useful, not_now or other).
warehouse-suggestions-resume brings a dismissed suggestion back.