Motivation:
Commonly, UUID are used in clustered environment, where numerical primary keys are prone to conflicts. But, for avoiding conflicts in clustered environments, most relational databases relies on numerical sequences. In other words, each node from the cluster has its own offset used for generating identifiers. Alternatively, but not better, is to use UUID primary keys. But, UUID comes with performance penalties in clustered indexes because their lack of sequentiality and have a bigger memory footprint too. Nevertheless, if you decide to use UUID and assign them manually then here it i how.
150+ PERSISTENCE PERFORMANCE ITEMS
THAT WILL ROCK YOUR APPS
Description:
This application is an example of manually assigning UUID identifiers.
Key points:
Store UUID in a BINARY(16) column:
Manually assign the UUID value (for example, via UUID.randomUUID() ):
Testing time:
Check as well:
Tam Ta Da Dam! :) The complete application is available on GitHub.
If you need a deep dive into the performance recipes exposed in this repository then I am sure that you will love my book "Spring Boot Persistence Best Practices".
Comments