Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rUbyR-00Byel-FM for pgsql-hackers@arkaria.postgresql.org; Tue, 30 Jan 2024 00:27:36 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1rUbyQ-001SyS-I4 for pgsql-hackers@arkaria.postgresql.org; Tue, 30 Jan 2024 00:27:34 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rUbyP-001SyJ-B1 for pgsql-hackers@lists.postgresql.org; Tue, 30 Jan 2024 00:27:34 +0000 Received: from sonic301-20.consmr.mail.gq1.yahoo.com ([98.137.64.146]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1rUbyJ-0043ar-BY for pgsql-hackers@postgresql.org; Tue, 30 Jan 2024 00:27:31 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com.au; s=s2048; t=1706574445; bh=pB9z2N00lM6bL/QviU9Gy/PFedj337jgz8IapIlFOq8=; h=Date:From:To:Cc:In-Reply-To:References:Subject:From:Subject:Reply-To; b=ntGIqoo790ZXHo+myeTEegIzeIUrJNFYHhvQCJ+0NkYgsQ+TcHRjE+q940Sg0CZ44jl5XIQdoy5CTtFjEhXLc4mRThSrtLZD08gYXAymTQWfHaQ2CtmtWURFOYUwLFz1Nol1ayb2YTgEkrsjiGiMEwx2cWS2LMAlHW5l+rJGWG4ZdU/3lf8XY0brQWtpD+l+oHnJcxgbsFvz9bHQ1xpY1qFzgzUqyjuN2GDBb0au7nl6GXUQ1ws+C2azNewk0DSgeD6aYb2IED3X/ZoLXTVX04k5xVpY+6ixJK5Ht3jU+abP7rFIHLXkcBTR7Sz+TId9RpnFa4hmGsa6knHGq5EK2A== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1706574445; bh=lQfDY+wVtEyabuJM/UTo8lBjaa1Orv0NpJUE9h4PTjr=; h=X-Sonic-MF:Date:From:To:Subject:From:Subject; b=goj6GGT3nvj5gFExFnZOvSy0WC1uHQIQKK7xHNyQ22Tbz6HuoK+LrXtKRw8MwRwMSGIa8tIhjEk6RrE7PqmTb0uajgWWuiBQjOjMc8NV9Sgpu7U4MalFEJyu0S1DINfFFqmF1+puqz62ESPGJTOYjp0vCVQMGBvD+uCgwod+pYZysJUcrCGA4TQoucifDFXIGwuVPXC7iFGI4VH5G3h12cciSbZkHX/Ofl/LLeb4jm7rllgvK8FtBv0gALlO7bUalcygc/tbltgDZVFdTR2Um5koogKvT5e5qw5/FDEob0rRGtu6f1yXZ8sCAeiLY41ZgGS2r7tJZGbRyYqJD3sdsA== X-YMail-OSG: ZLq55doVM1kj7NyO.nHh9N3aqoN1KK6Ln2zWLvgFpTzmlVaBle2qo3CeTsD8USn .58Bopd1Qgu7B_BFf4rTWIjyq.L1I.pL704cmkTuilkCydFHwkCxIcmrOpQliccJvN7PB6scHXeM a7IOp1IxP65uKHTFOfkg5PPtWm3ScX69.2t1gyASfdnBL70D_DfexkREkZlbJzgNuVWFiRoK0npq Pk87DVEezDXXx3LAjlpACThF3VtrQSU8n5Vlm.Gn1.2UnMcw2vt91m7WHjF.btSN626KpFqYfbT_ S9cF2UCDwgs8lMy17qRlYyGE1OtMtMx.jEgdguqsnghQqqRGNmKdl4RwjO_Bvngp6zJbWlswNr.B YYfe7UhvyHdwhf5A.V0GKDiGS_bxXXIZ8iSUOEYHYrBH7V81YisoWPWDJNquZWbxTTFT75O7YZMN oOH8kicCppJl4v7JJxU3_pVMWCGm7MtSWhoHa.A5jyWn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9gbB3S7o_Oy2QOCEslytm5wgoLU8r8pSdS6 1G3DmxXCU_nhCm7IF5yz3ERfV7ijlJjADm1wVMt7NCC_037idBYPmhx_xiOyIc7d5s8.5TcRI4hq 4pSCyQzLIqdJd9zzrOuWoYjb3tJ5b9SWjADdsd5lZ44uKV9cs6SbGnabQ1vNiJfF5PVas4qAfDMW wPRSTl10B_qO.ugpN9iIt5HFGgoZd2_OTsael4O8vSBR4.2bcIeeBpAf5lOH6iDuzRNpuwB2aD7f O9Xp69fKLBPyjQ4blCq9iIT1IO6b1JpVlsLuMM6qb8uw4J3XFtecUe.Tmx_1lgimQYovgbiQygB2 ZWqRikakPdcmU6w_1C6gyxA0vB3gJxUA2P5u74yGgyXIMk7_fF2eQhTxa6V3I6nxJTa7wA0zwuBz FoP8nrqG6DKU0dompewsJ593ZFZB7bIhQTUIwgTGTz.wNrvyBJzFRtZ8Qqvk.W0YZWi8oyDRW5OV PyZ2lpbYbjTrEMHzD0ajzVbA.EKMIv9FKEgaavWuTsXKLlk934mzTNEQgyVP0Hr4bpfYwW0SjFmI rLBQdIilpIgaCuJO.bM9sSw_hRIyoAw4uZ8RpXVqF0qoUWhXhTc9RlojyH7ZMvDkpYues3dCEMnY zC3qtXC._zS7CSE8f49Spel9StR0MGGYW2dxFxxdGmp39EV_Q83_m9spDAZhCgOZQNwy3KLqAaSg GGqslMs2_MhqbVlGJIayFYDuyBgqpAnKVdK5OFFDB.hz1JjI8J1LYVCO2 X-Sonic-MF: X-Sonic-ID: 177514b7-6d64-4c71-91ae-c8b9adb835be Received: from sonic.gate.mail.ne1.yahoo.com by sonic301.consmr.mail.gq1.yahoo.com with HTTP; Tue, 30 Jan 2024 00:27:25 +0000 Date: Tue, 30 Jan 2024 00:27:21 +0000 (UTC) From: Sergey Prokhorenko To: "Andrey M. Borodin" Cc: pgsql-hackers mailing list , Aleksander Alekseev , =?UTF-8?Q?Przemys=C5=82aw_Sztoch?= , Nikolay Samokhvalov , "David G. Johnston" , Jelte Fennema-Nio , Nick Babadzhanian , Mat Arye , Peter Eisentraut , Tom Lane , Daniel Gustafsson , Matthias van de Meent , Nikolay Samokhvalov , "Kyzer Davis (kydavis)" , Andres Freund , "brad@peabody.io" , Kirk Wolak Message-ID: <1945125834.2044089.1706574441164@mail.yahoo.com> In-Reply-To: <5932FFF8-4E5F-44DC-8FEA-22E8302759C7@yandex-team.ru> References: <1003561938.6914482.1704452267331@mail.yahoo.com> <80E8F728-FC9C-461E-9B61-332E3AAEC066@yandex-team.ru> <67eb8a02-f35c-af10-1615-afae0f9f7548@sztoch.pl> <8A52AED1-2CA6-403C-8B5B-D24EA8D58616@yandex-team.ru> <9CE1E513-B11A-4C59-980E-D61EC56716E7@yandex-team.ru> <0A0D7507-C434-46AC-BCC4-1166C5A2742A@yandex-team.ru> <1459150585.359059.1706132985954@mail.yahoo.com> <00B784AB-5B52-4CC7-8A0D-B1C0C53B52DC@yandex-team.ru> <1014147035.642629.1706202245918@mail.yahoo.com> <5932FFF8-4E5F-44DC-8FEA-22E8302759C7@yandex-team.ru> Subject: Re: UUID v7 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_2044088_24612575.1706574441162" X-Mailer: WebService/1.1.22046 YMailNorrin Content-Length: 9135 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk ------=_Part_2044088_24612575.1706574441162 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Andrey, I understand and agree with your goals.=C2=A0But instead of dangerous univ= ersal=C2=A0functions, it is better to develop=C2=A0safe highly specialized = functions that implement only these goals. There should not be a function uuidv7(T) from an arbitrary timestamp, but t= here should be a special function that implements your algorithm: uuidv8(no= w() + '1 century' * random(0,10)). I replaced 1 day with 1 century because the spread of 1 day is too small. O= ver time, records will be inserted between existing records, which is undes= irable. Similarly, if we need to calculate the partition id, then we do not need to= use the uuid_extract_time() function to provide the extracted timestamp, t= he accuracy of which cannot be guaranteed. Instead, we need to give exactly= the partition id, calculated using the uuidv7 timestamp. For example, part= itions may have approximately a month interval between each other. As for the documentation, it must be indicated that the UUIDv7 structure is= not timestamp + random, but timestamp + randomly seeded counter + random, = like in all advanced implementations. Sergey Prokhorenko sergeyprokhorenko@yahoo.com.au ______________________________________________________________=20 On Monday, 29 January 2024 at 09:32:54 pm GMT+3, Andrey M. Borodin wrote: =20 =20 =20 > On 25 Jan 2024, at 22:04, Sergey Prokhorenko wrote: >=20 > Aleksander, >=20 > In this case the documentation must state that the functions uuid_extract= _time() and uuidv7(T) are against the RFC requirements, and that developers= may use these functions with caution at their own risk, and these function= s are not recommended for production environment. Refining documentation is good. However, saying that these functions are no= t recommended for production must be based on some real threats. >=20 > The function uuidv7(T) is not better than uuid_extract_time(). Careless d= evelopers may well pass any business date into this function: document date= , registration date, payment date, reporting date, start date of the curren= t month, data download date, and even a constant. This would be a profanati= on of UUIDv7 with very negative consequences. Even if the developer pass constant time to uuidv7(T) they will get what th= ey asked for - unique identifier. Moreover - it still will be keeping local= ity. There will be no negative consequences at all. On the contrary, experienced developer can leverage parameter when data loc= ality should be reduced. If you have serveral streams of data, you might wa= nt to introduce some shift in reduce contention. For example, you can generate uuidv7(now() + '1 day' * random(0,10)). This = will split 1 contention point to 10 and increase ingestion performance 10x-= fold. > On 29 Jan 2024, at 18:58, Junwang Zhao wrote: >=20 > If other timestamp sources or > a custom timestamp epoch are required, UUIDv8 MUST be used. Well, yeah. RFC says this... in 4 capital letters :) I believe it's kind of= a big deficiency that k-way sortable identifiers are not implementable on = top of UUIDv7. Well, let's go without this function. UUIDv7 is still an imp= rovement over previous versions. Jelte, your documentation corrections looks good to me, I'll include them i= n next version. Thanks! Best regards, Andrey Borodin. =20 ------=_Part_2044088_24612575.1706574441162 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Andrey,
=
I understand and ag= ree with your goals. But instead of dangerous universal&= nbsp;functions, it is better to develop safe highl= y specialized functions that implement only these goals.

There should not be a function uuidv7(T) from an arbitrary timestamp= , but there should be a special function that implements your algorithm: uu= idv8(now() + '1 century' * random(0,10)).

I replac= ed 1 day with 1 century because the spread of 1 day is too small. Over time= , records will be inserted between existing records, which is undesirable.<= /div>

Similarly, if we need to calculate the partition i= d, then we do not need to use the uuid_extract_time() function to provide t= he extracted timestamp, the accuracy of which cannot be guaranteed. Instead= , we need to give exactly the partition id, calculated using the uuidv7 tim= estamp. For example, partitions may have approximately a month interval bet= ween each other.

As for the documentation, it must be indicated that the UUIDv7 structure i= s not timestamp + random, but timestamp + randomly seeded counter + random,= like in all advanced implementations.


Sergey Prokhorenko

sergeyprokhorenko@yahoo.com.au

_____________________= _________________________________________


=20
=20
On Monday, 29 January 2024 at 09:32:54 pm GMT+3, Andrey= M. Borodin <x4mmm@yandex-team.ru> wrote:




> On 25 Jan 2024, at 22:04, Sergey Prokhorenko <sergeyprokhorenko@yahoo.com.au> wrote:
> <= br clear=3D"none">> Aleksander,
>
> In this case the documentation must state that the functions uuid_ex= tract_time() and uuidv7(T) are against the RFC requirements, and that devel= opers may use these functions with caution at their own risk, and these fun= ctions are not recommended for production environment.
Refining documentation is good. However, saying that these= functions are not recommended for production must be based on some real th= reats.

>
> Th= e function uuidv7(T) is not better than uuid_extract_time(). Careless devel= opers may well pass any business date into this function: document date, re= gistration date, payment date, reporting date, start date of the current mo= nth, data download date, and even a constant. This would be a profanation o= f UUIDv7 with very negative consequences.

Even if the developer pass constant time to uuidv7(T) they will get wha= t they asked for - unique identifier. Moreover - it still will be keeping l= ocality. There will be no negative consequences at all.
O= n the contrary, experienced developer can leverage parameter when data loca= lity should be reduced. If you have serveral streams of data, you might wan= t to introduce some shift in reduce contention.
For examp= le, you can generate uuidv7(now() + '1 day' * random(0,10)). This will spli= t 1 contention point to 10 and increase ingestion performance 10x-fold.

> On 29 Jan 2024, at 18:58, Junwang Zh= ao <zhjwpku@gmail.com> wrote:
> =
> If other timestamp sources or
>= ; a custom timestamp epoch are required, UUIDv8 MUST be used.

Well, yeah. RFC says this... in 4 capital letters := ) I believe it's kind of a big deficiency that k-way sortable identifiers a= re not implementable on top of UUIDv7. Well, let's go without this function= . UUIDv7 is still an improvement over previous versions.
=

Jelte, your documentation corrections= looks good to me, I'll include them in next version.
Thanks!


Best regards, Andrey Borodin.
------=_Part_2044088_24612575.1706574441162--