The first experiment showed that both stores could handle our flexible workflow data. It did not show a reason to add another database. This follow-on asks a narrower question: where could MongoDB deliver enough benefit to earn a bounded role in Odin?
For the two workloads we tested, PostgreSQL stays Odin’s default. MongoDB demonstrated a repeatable advantage over monolithic JSONB in two 64 KiB session workloads. Neither cleared the bar against the stronger PostgreSQL design. Across all 17 prespecified outcomes, no scenario earned a MongoDB platform-primitive recommendation. The scope was narrow: one shared, throttled machine, synthetic session documents, partial writes and attribute queries; replicated failover, recovery, backup and retention were not measured. A study of the mechanisms MongoDB is built around exists as a design draft and has not run.
The amended main completed 99,000 measured requests across 105 cells; a separate-seed reproduction completed 19,800 requests across 21 cells. The useful finding is concrete: data layout can remove the apparent need for a second database. MongoDB remains a plausible candidate for other contracts, with an explicit burden of proof.
Two plausible boundaries
Mutable session working state. A bounded object can contain heterogeneous tool state with a stable identity and version. We test one known hot field and distributed updates across 64 existing numeric fields. Full-document reads stay in the workload, so reconstruction cost counts. This is aggregate state, not authoritative conversation history, dispatch receipts or work-order transitions.
Artifact or tool metadata search. A separate projection could expose changing scalar attributes while preserving immutable content identity and governed provenance elsewhere. We test numeric equality, string equality, ranges, present keys with an empty-value marker, and existence on both known and withheld keys. Large artifact bodies are outside this kernel.
These boundaries are informed by source inspection, not production traffic measurements. Record sizes, query distributions and update frequencies are synthetic stress choices. The study tests tenant-key scoping; it does not establish authenticated tenant isolation.
Give PostgreSQL its strongest tested alternative
| Contract | MongoDB | PostgreSQL alternatives |
|---|---|---|
| Bounded mutable state | Native atomic field updates with version compare-and-set | Monolithic JSONB path updates; a specialized hot row or generic field-override table, with complete read reconstruction |
| Dynamic scalar queries | Tenant-compound wildcard index | JSONB GIN; a typed attribute child table with B-tree indexes and parent joins |
Each store returns the same small mutation acknowledgment or ordered query projection. Partial writes do not fetch and validate the full document first. The amended run uses PostgreSQL synchronous commits with wal_sync_method=fsync_writethrough and unchanged MongoDB majority-plus-journal writes. This addresses a platform-specific flush mismatch described below; it is not a power-loss recovery proof. Index build, ingestion, maintenance and storage are reported alongside request latency.
Why we amended the durability settings
The original counted attempt was interrupted after 81 completed cells. Its source and records are retained, but those cells are excluded from the amended main and reproduction denominators. The original PostgreSQL configuration had fsync=on and synchronous_commit=on, yet macOS selected wal_sync_method=open_datasync. Source inspection of the pinned MongoDB storage engine showed that its sync implementation attempts a physical write-cache flush when supported. Nominal durable-write settings therefore did not establish equivalent physical flush behavior.
Before restarting measurement, we froze a separate version-2 amendment and verified PostgreSQL fsync_writethrough. MongoDB journal acknowledgment settings and the decision gates remain unchanged. We did not trace MongoDB’s actual syscall branch or simulate a power failure. This correction narrows a known comparability problem; it does not establish equivalent failure behavior on every device. The original cumulative log counters include setup and smoke activity and must not be read as per-request benchmark timings.
The evidence archive preserves the interrupted attempt, its full curated observations, read-only durability diagnosis, and exact original sources alongside the amended sources. No original-attempt observations are pooled into the completed version-2 results. The integrity manifest records the distinction and file hashes.
The frozen screening rule
A candidate must reduce median request latency by at least 30% against each PostgreSQL alternative, in at least four of five paired repetitions. Its median paired p95 ratio must be no worse than 1.10, and its maximum paired data-plus-index storage ratio no worse than 2. Attribute-query candidates also face a maintenance veto: update median latency must stay within twice the best PostgreSQL design.
The protocol and source were frozen locally before each counted attempt; this is not a claim of public pre-registration. Correctness failures, durability drift or source drift reject a candidate. A separate full-matrix repetition with a different seed must reproduce the direction and the 30% median reduction, with the same correctness, p95 and storage gates. This is a local screening rule, not statistical proof of a production advantage.
All 17 prespecified outcomes are reported: six session profile/size combinations, the fixed mixed query workload, and ten query group/class combinations. A pooled query win cannot support an individual-class claim. Possible outcomes are candidate-advantage, jsonb-only-advantage, no-demonstrated-advantage or invalid-or-incomplete.
What is measured
The session matrix uses 1,000 seeded records across ten tenants, 8 or 64 KiB cold bodies, concurrency ten and three update/read mixes: 80/20 for the known hot field, 90/10 for distributed writes and 50/50 for distributed reads. For the distributed profiles, ten active records are preconditioned before warm-up so all 64 mutable paths have already been exercised. Total serialized documents include additional identity and nested-state bytes.
The query matrix uses 10,000 records, 20 attributes per record and 200 possible keys. Each cell measures 500 queries evenly covering twenty positive cases, then 100 maintenance updates. Full-match, empty-result, wrong-type and absent-key checks run outside timing. Both kernels use five paired repetitions with fixed rotating arm order.
Request timing includes driver work and required reconstruction, while fixture generation, oracle comparison and evidence hashing remain outside it. Real Temporal activity execution and a commit-before-acknowledgment retry are checked separately. Temporal uses its development SQLite history store; MongoDB is not being tested as its internal persistence backend.
Results and evidence
Two JSONB-only advantages; zero candidate advantages. Every number below is MongoDB request latency divided by the named PostgreSQL alternative. Lower is better for MongoDB; 0.700 is the 30% reduction threshold. Main values are medians of five paired ratios. Repeat values come from the separate-seed repetition. Outcome labels also apply the consistency, p95, storage, correctness and reproduction gates; a favorable ratio alone does not decide the result.
| Scenario | Main / JSONB | Main / optimized PG | Repeat / JSONB | Repeat / optimized PG | Evaluated outcome |
|---|---|---|---|---|---|
| Known hot field, 8 KiB | 0.985 | 1.014 | 0.968 | 1.007 | No demonstrated advantage |
| Known hot field, 64 KiB | 0.511 | 1.038 | 0.599 | 0.924 | JSONB-only advantage |
| Distributed writes (90%), 8 KiB | 0.982 | 1.024 | 0.967 | 1.013 | No demonstrated advantage |
| Distributed writes (90%), 64 KiB | 0.674 | 1.011 | 1.153 | 2.330 | No demonstrated advantage |
| Distributed reads (50%), 8 KiB | 0.988 | 1.253 | 0.359 | 2.270 | No demonstrated advantage |
| Distributed reads (50%), 64 KiB | 0.407 | 1.263 | 0.571 | 1.329 | JSONB-only advantage |
For the 64 KiB known-hot workload, MongoDB’s main ratio against JSONB was 0.511, reproducing at 0.599. Against the specialized PostgreSQL design, the corresponding ratios were 1.038 and 0.924. For 64 KiB distributed read-heavy state, JSONB ratios were 0.407 and 0.571, while the base-plus-override PostgreSQL design gave ratios of 1.263 and 1.329. Both are genuine benefits over the monolithic JSONB baseline, without the required benefit over the strongest tested PostgreSQL alternative.
The 64 KiB distributed write-heavy case illustrates why reproduction matters: its main JSONB ratio was 0.674, but the separate repeat gave 1.153. It did not qualify. We report that reversal rather than selecting the favorable main result.
| Scenario | Main / JSONB GIN | Main / typed attributes | Repeat / JSONB GIN | Repeat / typed attributes | Evaluated outcome |
|---|---|---|---|---|---|
| Fixed mixed query workload | 1.917 | 2.708 | 2.529 | 3.016 | No demonstrated advantage |
| Known keys · Numeric equality | 2.854 | 2.621 | 4.008 | 2.897 | No demonstrated advantage |
| Known keys · String equality | 1.839 | 2.761 | 2.314 | 2.898 | No demonstrated advantage |
| Known keys · Numeric range | 1.371 | 1.685 | 1.820 | 1.834 | No demonstrated advantage |
| Known keys · Explicit empty marker | 2.036 | 4.332 | 2.208 | 4.769 | No demonstrated advantage |
| Known keys · Key existence | 2.461 | 2.394 | 3.054 | 2.431 | No demonstrated advantage |
| Withheld keys · Numeric equality | 2.897 | 2.774 | 4.230 | 3.095 | No demonstrated advantage |
| Withheld keys · String equality | 1.706 | 2.585 | 2.297 | 2.886 | No demonstrated advantage |
| Withheld keys · Numeric range | 1.431 | 1.600 | 1.994 | 2.043 | No demonstrated advantage |
| Withheld keys · Explicit empty marker | 1.808 | 4.487 | 3.676 | 4.734 | No demonstrated advantage |
| Withheld keys · Key existence | 3.107 | 2.148 | 2.621 | 2.133 | No demonstrated advantage |
MongoDB’s mixed metadata-query ratio was 1.917 against JSONB GIN and 2.708 against the typed attribute table; the repeat gave 2.529 and 3.016. Every measured query class had a slower median for this wildcard-index design in both runs. The footprint tradeoff is real: the maximum paired MongoDB storage ratio was about 0.089 against typed attributes and 0.806 against GIN. These data-plus-index observations support a storage tradeoff, not an overall latency win or an operating-cost conclusion.
The complete evaluated decision contains every paired median, p95, storage and maintenance ratio and each gate verdict. The 105 main cells and separate reproduction report retain absolute timings, setup/maintenance measurements and all strata.
The main completed 810 kernel checks; the repeat completed 162. Each also completed 30 real Temporal mutations over 33 activity attempts and nine integration receipts: duplicate workflow rejection, committed-CAS reconciliation after a lost acknowledgment, and same-code mutation-history replay for each session design. This is bounded reconciliation of dedicated known states, not general exactly-once business receipts.
A separate verifier passed its audit of all 118,800 operation records, 126 cells and 342 snapshots, checking raw statistics, expected state, source hashes and durability evidence. It confirmed the seventeen outcomes: two JSONB-only advantages and zero candidate advantages. These audit totals cover both runs; their timing samples remain separate. Audit receipts are retained with each run in the evidence archive.
Main elapsed time was 2,007,973 ms (33 min 28 sec); reproduction took 267,171 ms (4 min 27 sec). Both stayed within the frozen 60-minute, 4 GiB owned-process RSS and 10 GiB runtime-disk limits. Elapsed time includes preparation and correctness work; it is not a throughput measurement.
- Study summary, main report, and all seventeen decision outcomes.
- Readable protocol summary and source, fixture and runtime manifest summary. Exact original and amended frozen inputs are preserved in the archive.
- Raw observations and exact frozen source archive, including separate reproduction, Temporal histories, compact session projections, full attribute snapshots, retained smoke metadata and the excluded interrupted main.
- Export policy and integrity hashes, plus initial and supplemental host observations.
- Clean-clone reproduction guide, with manual pinned-binary preparation and the actual bootstrap interface.
What would change the platform decision?
For these workloads, the current decision is to keep PostgreSQL as the default and avoid adding MongoDB as a platform dependency on this evidence. Where monolithic JSONB is expensive, first test the demonstrated PostgreSQL hot-row or override-table alternative. This experiment has found a real MongoDB benefit against one layout; it has not found the additional benefit needed to carry another platform primitive.
What would change that decision is a repeatable advantage against the strongest practical alternative for a real Odin contract, large enough to pay for the additional operational burden. The next experiment should target a specific opportunity:
- A separately frozen MongoDB index design that better combines tenant filtering, dynamic predicates and ordered projections. The present wildcard arm is one implementation, not an exhaustive MongoDB tuning search.
- Representative session/artifact distributions and observed update/read proportions, preserving trusted authorization and the same correctness contract. Synthetic sizes and mixes cannot establish how often a candidate matters in Odin.
- Deployment-target Linux measurements, replicated failover/recovery, backup and retention behavior, plus operating and migration cost. The current local native tier does not answer these.
- A controlled engineering-maintenance comparison: implement the same evolving requirements, count defects and effort, and include the PostgreSQL alternatives. Developer productivity was not measured here.
A future win could justify a bounded pilot for that aggregate or search contract. Billing, cross-entity integrity, governed histories and immutable receipts retain their own authority and evidence requirements. The result does not establish that MongoDB is universally unsuitable.
Limits on the inference
This was one shared, throttled macOS AMD64 host. The amended main began with a reported CPU speed limit of 42%; supplemental samples observed 35% and 77%. Supporting archive-listing activity also occurred during the main and is recorded; its exact overlap with timing cells was not instrumented. The separate repetition used a quieter owned execution lane, but still shares the host and is not a multi-machine replication. These conditions limit causal and capacity claims.
Full session values were compared with the independent oracle before evidence storage. Retained session projections replace reconstructable synthetic cold bodies with byte counts and SHA-256 digests; they are not full stored payload bodies. Attribute snapshots remain complete. Export normalization changes host identifiers and local paths while retaining original/exported hashes.
Synthetic fixtures only. The original workflow experiment remains unchanged. This study is also separate from EXP 010’s wire-compatibility work. The protocol was locally frozen, not publicly pre-registered. Results support workload-specific screening only.