<div dir="ltr"><div class="gmail_quote"><div dir="ltr"><div>Today, the JDK includes support for generating random UUIDs ("v4") and name-based UUID's ("v3"). These two types have random leading bits, and that results in poor performance in database systems that have sorted indexes (i.e. most of them).</div><div><br></div><div>RFC 9562 [1], an update to the original UUID RFC, solves this by including standard formats for time-ordered UUIDs, namely the v7 variant:</div><div><br></div><div>> UUID versions that are not time ordered, such as UUIDv4 (described in
<a href="https://www.rfc-editor.org/rfc/rfc9562.html#uuidv4" target="_blank">Section 5.4</a>), have poor database-index locality. This
means that new values created in succession are not close to each
other in the index; thus, they require inserts to be performed at
random locations. The resulting negative performance effects on the
common structures used for this (B-tree and its variants) can be
dramatic.</div><div><br></div><div>> Time-ordered monotonic UUIDs benefit from greater database-index
locality because the new values are near each other in the index. As
a result, objects are more easily clustered together for better
performance. The real-world differences in this approach of index
locality versus random data inserts can be one order of magnitude or
more.</div><div><br></div><div>Now that v7 UUIDs are well-defined, does anyone think it would be useful to have in-jdk support for their generation? I am willing to do the work to shepherd a proposal forward, given consensus and interest.<br></div><div><br></div><div>[1] <a href="https://www.rfc-editor.org/rfc/rfc9562.html" target="_blank">https://www.rfc-editor.org/rfc/rfc9562.html</a></div></div>
</div></div>
<br>
<div style="font-family:Arial,Helvetica,sans-serif;font-size:1.3em"><hr></div><div style="text-align:justify"><font size="1"><font color="#808080" face="Arial, Helvetica, sans-serif">Confidentiality note: This e-mail may contain confidential information from Nu Holdings Ltd and/or its affiliates. If you have received it by mistake, please let us know by e-mail reply and delete it from your system; you may not copy this message or disclose its contents to anyone; for details about what personal information we collect and why, please refer to our <a href="https://nubank.com.br/contrato/politica-privacidade/" target="_blank">privacy policy</a>.</font></font></div>