Re: UUID v1 optimizations...

2019-05-25 Thread Morris de Oryx
I'm not worthy to post here, but a bit of a random thought. If I've followed the conversation correctly, the reason for a V1 UUID is partly to order and partition rows by a timestamp value, but without the cost of a timestamp column. As I was told as a boy, "Smart numbers aren't." Is it _absolutel

Re: UUID v1 optimizations...

2019-05-25 Thread Tomas Vondra
On Sun, May 26, 2019 at 01:49:30AM +0200, Ancoron Luciferis wrote: On 26/05/2019 00:14, Tomas Vondra wrote: On Sat, May 25, 2019 at 05:54:15PM -0400, Tom Lane wrote: Ancoron Luciferis writes: On 25/05/2019 16:57, Tom Lane wrote: (4) it in fact *wouldn't* do anything useful, because we'd stil

Re: UUID v1 optimizations...

2019-05-25 Thread Ancoron Luciferis
On 26/05/2019 00:14, Tomas Vondra wrote: > On Sat, May 25, 2019 at 05:54:15PM -0400, Tom Lane wrote: >> Ancoron Luciferis writes: >>> On 25/05/2019 16:57, Tom Lane wrote: (4) it in fact *wouldn't* do anything useful, because we'd still have to sort UUIDs in the same order as today, meani

Re: UUID v1 optimizations...

2019-05-25 Thread Tomas Vondra
On Sat, May 25, 2019 at 06:38:08PM -0400, Tom Lane wrote: Tomas Vondra writes: On Sat, May 25, 2019 at 05:54:15PM -0400, Tom Lane wrote: What you might want to think about is creating a function that maps UUIDs into an ordering that makes sense to you, and then creating a unique index over tha

Re: UUID v1 optimizations...

2019-05-25 Thread Ancoron Luciferis
On 25/05/2019 23:54, Tom Lane wrote: > Ancoron Luciferis writes: >> On 25/05/2019 16:57, Tom Lane wrote: >>> (4) it in fact *wouldn't* do anything useful, because we'd still have >>> to sort UUIDs in the same order as today, meaning that btree index behavior >>> would remain the same as before. P

Re: UUID v1 optimizations...

2019-05-25 Thread Tom Lane
Tomas Vondra writes: > On Sat, May 25, 2019 at 05:54:15PM -0400, Tom Lane wrote: >> What you might want to think about is creating a function that maps >> UUIDs into an ordering that makes sense to you, and then creating >> a unique index over that function instead of the raw UUIDs. That >> would

Re: UUID v1 optimizations...

2019-05-25 Thread Tomas Vondra
On Sat, May 25, 2019 at 05:54:15PM -0400, Tom Lane wrote: Ancoron Luciferis writes: On 25/05/2019 16:57, Tom Lane wrote: (4) it in fact *wouldn't* do anything useful, because we'd still have to sort UUIDs in the same order as today, meaning that btree index behavior would remain the same as be

Re: UUID v1 optimizations...

2019-05-25 Thread Tom Lane
Ancoron Luciferis writes: > On 25/05/2019 16:57, Tom Lane wrote: >> (4) it in fact *wouldn't* do anything useful, because we'd still have >> to sort UUIDs in the same order as today, meaning that btree index behavior >> would remain the same as before. Plus UUID comparison would get a lot >> more

Re: UUID v1 optimizations...

2019-05-25 Thread Ancoron Luciferis
On 25/05/2019 21:00, Vitalii Tymchyshyn wrote: > I am not sure why do you want to change on-disk storage format? If we > are talking about indexes, it's more about comparison function (opclass) > that is used in an index.  > Am I wrong? I don't "want" to change the on-disk format of the v1 UUID's

Re: UUID v1 optimizations...

2019-05-25 Thread Ancoron Luciferis
On 25/05/2019 21:00, Vitalii Tymchyshyn wrote: > I am not sure why do you want to change on-disk storage format? If we > are talking about indexes, it's more about comparison function (opclass) > that is used in an index.  > Am I wrong? I don't "want" to change the on-disk format of the v1 UUID's

Re: UUID v1 optimizations...

2019-05-25 Thread Vitalii Tymchyshyn
I am not sure why do you want to change on-disk storage format? If we are talking about indexes, it's more about comparison function (opclass) that is used in an index. Am I wrong? сб, 25 трав. 2019 о 11:21 Ancoron Luciferis < ancoron.lucife...@googlemail.com> пише: > On 25/05/2019 16:57, Tom Lan

Re: UUID v1 optimizations...

2019-05-25 Thread Ancoron Luciferis
On 25/05/2019 16:57, Tom Lane wrote: > Ancoron Luciferis writes: >> So I investigated the PostgreSQL code to see how it is handling UUID's >> with respect to storage, sorting, aso. but all I could find was that it >> basically falls back to the 16-byte. > > Yup, they're just blobs to us. > >> Af

Re: UUID v1 optimizations...

2019-05-25 Thread Ancoron Luciferis
On 25/05/2019 16:19, Peter Eisentraut wrote: > On 2019-05-25 15:45, Ancoron Luciferis wrote: >> So, my question now is: Would it make sense for you to handle these >> time-based UUID's differently internally? Specifically un-shuffling the >> timestamp before they are going to storage? > > It seems

Re: UUID v1 optimizations...

2019-05-25 Thread Tom Lane
Ancoron Luciferis writes: > So I investigated the PostgreSQL code to see how it is handling UUID's > with respect to storage, sorting, aso. but all I could find was that it > basically falls back to the 16-byte. Yup, they're just blobs to us. > After struggling to find a way to optimize things i

Re: UUID v1 optimizations...

2019-05-25 Thread Peter Eisentraut
On 2019-05-25 15:45, Ancoron Luciferis wrote: > So, my question now is: Would it make sense for you to handle these > time-based UUID's differently internally? Specifically un-shuffling the > timestamp before they are going to storage? It seems unlikely that we would do that, because that would br

UUID v1 optimizations...

2019-05-25 Thread Ancoron Luciferis
Hi all, Some time ago, I was having trouble with some rather high load OLTP application (in Java, but that doesn't really matter) that was using v1 UUID's for primary keys and after some time, the bloat of certain indexes went quite high. So I investigated the PostgreSQL code to see how it is han