mentat/test/datomish
Nick Alexander badec36aaa Completely rewrite main transaction logic to be faster.
This is almost complete; it passes the test suite save for retracting
fulltext datoms correctly.

There's a lot to say about this approach, but I don't have time to give
too many details.  The broad outline is as follows.  We collect datoms
to add and retract in a tx_lookup table.  Depending on flags ("search
value" sv and "search value type tag" svalue_type_tag) we "complete" the
tx_lookup table by joining matching datoms.  This allows us to find
datoms that are present (and should not be added as part of the
transaction, or should be retracted as part of the transaction, or
should be replaced as part of the transaction.  We complete the
tx_lookup (in place!) in two separate INSERTs to avoid a quadratic
two-table walk (explain the queries to observe that both INSERTs walk
the lookup table once and then use the datoms indexes to complete the
matching values).

We could simplify the code by using multiple lookup tables, both for the
two cases of search parameters (eav vs. ea) and for the incomplete and
completed rows.  Right now we differentiate the former with NULL checks,
and the latter by incrementing the added0 column.  It performs well
enough, so I haven't tried to understand the performance of separating
these things.

After the tx_lookup table is completed, we build the transaction from
it; and update the datoms materialized view table as well.  Observe the
careful handling of the "search value" sv parameters to handle replacing
:db.cardinality/one datoms.

Finally, we read the processed transaction back to produce to the API.
This is strictly to match the Datomic API; we might make allow to skip
this, since many consumers will not want to stream this over the wire.

Rough timings show the transactor processing a single >50k datom
transaction in about 3.5s, of which less than 0.5s is spent in the
expensive joins.  Further, repeating the processing of the same
transaction is only about 3.5s again!  That's the worst possible for the
joins, since every single inserted datom will already be present in the
database, making the most expensive join match every row.
2016-08-19 12:40:11 -07:00
..
test Use correct view for fulltext+non-fulltext. 2016-08-05 16:29:21 -07:00
api.cljc Add d/q; make query minimally schema aware. 2016-08-19 12:27:39 -07:00
db_test.cljc Completely rewrite main transaction logic to be faster. 2016-08-19 12:40:11 -07:00
jdbc_sqlite_test.clj Part 1: Fix testing errors. 2016-07-13 18:19:22 -07:00
promise_sqlite_test.cljs Part 1: Fix testing errors. 2016-07-13 18:19:22 -07:00
query_test.cljc Implement parts: Make the DB allocate and persist entity IDs. 2016-08-19 12:27:39 -07:00
schema_changes_test.cljc Bootstrap DB schema; persist and restore schema from materialized views. 2016-08-04 14:26:20 -07:00
sqlite_user_version_test.cljc Implement negation, predicates, external scalar bindings, <?q. r=nalexander 2016-07-25 17:08:00 -07:00
test.cljs Implement parts: Make the DB allocate and persist entity IDs. 2016-08-19 12:27:39 -07:00
test_macros_test.clj Add an async and async testing framework. 2016-07-12 13:56:26 -07:00
test_macros_test.cljs Part 1: Fix testing errors. 2016-07-13 18:19:22 -07:00