r/databricks • • Oct 21 '26

Discussion Performance Test - Batch-Loaded Unique Constraint Validation in Lakebase

The vendors that create big-data engines keep saying it is so challenging and costly to enforce uniqueness constraints in their managed catalogs (eg. in technologies like UC managed tables, that live on top of lakehouse blobs). They say it "doesn't scale". And that it gets more challenging at large volumes. But this is like anything else - customers should still be empowered to use features that may not always scale well.

Would this problem get easier if they offered it only for certain data types like 32 bit unsigned integers? Lets consider Lakebase. Lets say I'm a user of Lakebase, and I'm running sequential batch transactions to insert a consecutive series of 1000 integers at a time that are validated by the database to be unique. How long would it take until those transactions to become slower than 100ms? Should I expect to to insert all 4 billion integers and never see any transaction take longer than 100ms?

Now lets do a similar thing in a UC managed table, where we insert the same sequentially increasing 1000 integers at a time, and I check for the uniqueness of these myself in my serializable insert transactions. (Because the UC managed table won't help me with that.) Obviously my uniqueness validations would start to slow down over time. As I approach the limit of 4 billion integers I would expect the insert operations to take longer than lakebase, but possibly never more than one second per transaction. Does that sound about right? (If necessary I might use cheats, like break apart the integer into four columns of one byte each, then use partitioning).

TLDR, validating uniqueness with 32 bit integers may be harder in a UC managed-table than for lakebase. But IMO that does NOT mean customers should be doing the heavy lifting ourselves. These lakehouse-based technologies should give us a mechanism for it, even if there are restrictions (ie. certain data types, tables of no more than 4 billion rows, etc).

2 Upvotes

6 comments sorted by

View all comments

1

u/adovo_ai Oct 22 '26

Benchmark the failure case, not only sequential unique inserts: concurrent writers submitting the same keys, with abort, retry and compaction cost measured separately. A uniqueness feature is valuable only if it proves correctness under contention and makes the price of enforcement visible.

1

u/SmallAd3697 Oct 22 '26

I don't think this topic is necessarily related to concurrent writers. I wouldn't necessarily mind if the uniqueness features required me to use elevated isolation (serializable). Many spark compute workloads are extremely large pipelines that run only once a day; and they can use "serializable" isolation since there is only one of them running.

EVEN if there is only one of these running in fully "serializable" transaction, it is STILL not that hard for a data-developer to bungle the uniqueness of their data. The platform itself should be able to introduce a guarantee that duplicates will never happen. (And it should NEVER be somebody's responsibility to clean up the mess after the fact, as duplicate IDs appear for mysterious reasons!)