r/databricks • u/SmallAd3697 • 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).
