Repository navigation
Conversation
e71808f to
50704ea
Compare
…s on every materialize run (deeplethe#1267) Signed-off-by: Bogdan Szabo <bogdan@re-cinq.com>
50704ea to
3fc4945
Compare
|
Thanks, the logic and the tests look right to me, and moving the copy after the implied rows is a nice cleanup. One thing before it merges: this turns two per-row copies into two whole-base |
…ethe#1267) On a base with nothing new to copy, ON CONFLICT probed every row and the UNION sorted both source tables. UNION ALL plus a NOT EXISTS filter takes a 120k-row run from about 1.6 s to 1.26 s for both statements.
|
Thank you for the review, and for asking for the numbers. Good call: it turned up a cheap improvement, now pushed as d69d6c8. Setup. A scratch database with the five tables involved (same columns and indexes as on
What changed. The first version spent about 120 ms per statement sorting both source tables across every base for the EXPLAIN (ANALYZE, BUFFERS) for the fact_evidence statement after the changeThe Where it stays. The cost still grows with the size of the base: about 5 ms per thousand live typed rows for both statements. That is the same order as the other whole-base steps materialize already runs on every pass (steps 0 to 3, the implication scans and the attestation sync), so it doesn't add a new kind of cost. If you would rather it didn't grow with the base at all, the next step would be to limit the copy to statements whose evidence or role words changed since the last run. That needs a change marker we don't have today, so I'd suggest it as a follow-up rather than growing this PR. Happy to do it whichever way you prefer. |
Carry the role-words re-sync onto re-dev (upstream deeplethe#1544)
Part of #1267, PR 3 of 3, after #1428 and #1450. This builds decision 4 of ADR 0070.
materializecopied evidence and role words onto a typed row only while it was making or merging that row. So a statement re-pushed withlines: "58-70"still read40-52on its typed row. Now each run copies, for the whole base, the evidence and role-word rows of every live typed and implied row's statements that the row does not have yet. The copy is the sameON CONFLICT DO NOTHINGinsert as before. It readstyped_fact_sourcesandimplied_fact_sources, and it runs after the implied rows are written. Implied rows now get their statement's role words as well, which they never did. The per-row copies in the loop and inimply_in_txare gone, since this step covers them.As the 0121 revision of decision 1 left for this PR, a typed row whose statements disagree on a role now reads both values, the same as two live statements.
a_bound_statement_becomes_a_typed_factchanges for that. Its row now readssince 2019andsince 2021. 0070 gets a dated note on decision 1, its status moves to Implemented, and the README index follows.Tests:
a_re_push_that_moves_lines_moves_the_typed_rows_lines_toore-pusheslinesand reads only the new value and both chunks' evidence on the typed row, shows a run for another base leaves it alone, and ends with a re-push that addsmoodand retires the row.an_implied_row_reads_the_role_words_of_the_statement_that_implied_itreads the statement'slineson an implied row, then follows a re-push. The new behaviour fails ondev. Themoodcheck is from #1450 and only had a test for the drop direction, so that part is a plain characterization test, which I checked by breakingno_mood_spoken. I ran the store, server, core and cli suites against Postgres withUTOPIA_TEST_REQUIRE_DB=1, and fmt and clippy with-D warnings.The cost of the re-sync on a large base is still unmeasured, as the record says. Happy to add a bench if you'd like one before this goes in.
Thanks for taking a look!