FoundationDB/sql-layer — pull request #1588 by MMcM (2014-12-16 23:58:13+00:00)
Title: Add index check time statement

As noted on the card, all the common machinery shared with foreign key constraints already handled statement time checks, so this is mainly just a matter of adding some enum members and adjusting existing conditionals.

The bulk of the branch is a performance test to explore the multi-dimensional space of bulk insert settings. Since `PT` already meant profiling, I uncreatively chose `QT` and am open to suggestions for renaming. As one might suspect, some settings that help some times hurt other times. So optimization is not a straightforward hill climb.

The question remains what the best default index check time is. Unlike the `DELAYED_` versions, there are no semantic anomalies with the new ones. Every statement either completes or gets a uniqueness violation error.

* `IMMEDIATE` The current default (unchanged by this branch). Simple to understand and low-overhead in dumb uses. Perhaps appropriate if we expect careful users to always override the setting.
* `STATEMENT` A help if you're doing multi-row inserts but otherwise not batching. Not much of a hurt for single row, either. A bigger deficit (-15%) for multiple single-row inserts in a larger transaction because it does what amounts to a blocking check in a roundabout fashion and the commit latency isn't dominating.
* `STATEMENT_WITH_RANGE_CHECK` Almost as good as `DELAYED_WITH_RANGE_CACHE` if you are batching multiple monotonic (e.g., sequence) multi-row inserts in each transaction, because the RYW cache allows most to be checked locally. A little bit worse (-5%) for the worst case single-row auto-commit, because the second request isn't needed. Still pretty good for multiple single-row inserts in a larger transaction, because the synchronous check is still local.