docs: ADR 0004 — reject declarative partitioning; keep partial indexes + compaction (#418) - #433
Merged
Merged
Conversation
…s + compaction (#418) Investigating true nodes/edges partitioning by status surfaced two independent Postgres limitations that each break a core invariant: 1. A partitioned `nodes` can't keep `nodes.id` table-level unique (the partition key must be in the PK), so the edges→nodes FK can't be enforced by the DB. 2. The "one current edge per (from,to,type)" partial unique index can't be a parent-level index on a partitioned `edges`, so InsertEdge's atomic `ON CONFLICT ... WHERE status='current'` upsert — the idempotency behind link/remember — stops working. So partitioning and "keep integrity + the atomic edge upsert" are mutually exclusive here. The practical goal (small hot working set) is already met without compromise by #230 (current-tier partial indexes) + #385 (kb compact). At genuinely huge history the sound path is app-level *_archive tables + UNION in the history read paths, not partitioning. Records the decision in ADR 0004 + SYSTEM.md so it isn't re-litigated. kb partition is not added; #418 is superseded. Closes #418 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What & why
Closes #418 (scale). Documents the engineering decision not to add declarative table partitioning, with the reasoning, so it isn't re-litigated.
Investigating true
nodes/edgespartitioning bystatussurfaced two independent Postgres limitations, each breaking a core invariant:nodescan't keepnodes.idtable-level unique (the partition key must be in the PK), soedges.from_id/to_id → nodes.idcan't be DB-enforced.(from,to,type)" partial unique index (WHERE status='current') can't be a parent-level index on a partitionededges, soInsertEdge's atomicON CONFLICT (from_id,to_id,type) WHERE status='current' DO UPDATE— the idempotency behindlink/remember— stops working.So partitioning and "keep integrity + the atomic edge upsert" are mutually exclusive here.
Decision
Keep the already-shipped, no-compromise mechanism: #230 (current-tier partial indexes → hot index stays the size of live memory) + #385 (
kb compact→ reclaim heap bloat). At genuinely huge history (≫10M superseded rows) the sound path is app-level*_archivetables +UNIONin the history read paths (as-of #200, retention #363), not partitioning — a separate deliberate project if ever needed.Recorded in ADR 0004 + SYSTEM.md (§10).
kb partitionis not added.Docs-only.
🤖 Generated with Claude Code