News for hackers. Stuff that matters.
Re:Nanosecond timestamp collisions are common by mcv on Friday July 21, 2023 @05:20AM (#36811747)
But shouldn't that be a separate field then?
Re:Nanosecond timestamp collisions are common by mattashii on Friday July 21, 2023 @05:32AM (#36811822)
The logistics of combining fields in indexes and identifiers is relatively complex, while the logistics of indexing a single field is comparatively trivial. This is also why you don't ship timestamps using separate fields for second/minute/hour/day/month/year, but a single ISO-string or UNIX timestamp as representation: it makes querying and interpreting the value more consistent.
Re:Nanosecond timestamp collisions are common by frankreyes on Friday July 21, 2023 @06:37AM (#36812208)
Create a new column with an MD5 hash of the other columns. Easy.

/s

Re:Nanosecond timestamp collisions are common by rvnx on Friday July 21, 2023 @05:29PM (#36820062)
This is how it works, except it's not MD5 but a less-costly hash function
Re:Nanosecond timestamp collisions are common by eru on Saturday July 22, 2023 @10:53PM (#36832160)
MD5 is a useless hash function these days.

It's not cryptographically secure (anymore). And there are cheaper non-cryptographically secure hash functions.

Re:Nanosecond timestamp collisions are common by btilly on Friday July 21, 2023 @04:50PM (#36819533)
Disagree on "relatively complex".

    create index on $table ($field1, $field2);
Seems pretty simple to me.
Re:Nanosecond timestamp collisions are common by mattashii on Saturday July 22, 2023 @06:06AM (#36824934)
It is noy just the DDL of the primary table that needs to care about it, but also all foreign keys, DML, queries, APIs accessing the data, etc. Storing that UUIDv7 is likely going to be cheaper than pushing the cost of keeping a composite identity onto other components and systems that work with that data.
Re:Nanosecond timestamp collisions are common by btilly on Saturday July 22, 2023 @12:10PM (#36827424)
Well, that depends on how you manage it. An ORM will find it trivial. Custom SQL, not always so much.

That said, PostgreSQL offers https://www.postgresql.org/docs/current/rowtypes.html which gives you the best of both worlds. A single field which contains 2 fields that can later be extracted. So everywhere you can write a single field for joins, etc. But then when you need it broken out...

Re:Nanosecond timestamp collisions are common by madsbuch on Friday July 21, 2023 @05:34AM (#36811832)
I am curios about this, and might be misunderstanding what you mean.

Can you layout a demo architecture where you use multiple keys like you propose?

Re:Nanosecond timestamp collisions are common by junon on Friday July 21, 2023 @05:37AM (#36811847)
There are many DBMSes that combine columns into a singular primary key. Performance tradeoffs vary, especially when it comes to indexing.
Re:Nanosecond timestamp collisions are common by e12e on Friday July 21, 2023 @07:41AM (#36812664)
Any pure relational database design will eschew surrogate keys - most real-world systems will (should) add them back - because a surprising number of good natural keys end up changing (names change, phone numbers change, emails change, twitter handles become irrelevant/disappear, location of birth may change subject to geographic regions changing size...).

And on top of all that, there are efficiency concerns.

That said, at least for join tables AFAIK - there aren't often a need for row IDs beyond the involved foreign keys - unless you need to add meta data from other relations/tables...

Re:Nanosecond timestamp collisions are common by TRiG_Ireland on Friday July 21, 2023 @08:24AM (#36812990)
> location of birth may change

My British passport says I was born in Birr; my Irish passport says I was born in Galway. These are both correct, because they are answering different questions. (I was born in the town of Ballinasloe in County Galway, but my mother's place of residence at the time of my birth was the town of Birr in County Offaly.)

Re:Nanosecond timestamp collisions are common by pc86 on Friday July 21, 2023 @04:01PM (#36818897)
So British place of birth means "mother's residence" and not place of birth?
Re:Nanosecond timestamp collisions are common by rvnx on Friday July 21, 2023 @05:43PM (#36820266)
Official guidances here: https://assets.publishing.service.gov.uk/government/uploads/...

Could maybe be just a mistake when doing the UK registration ? It's an easy fix if wanted.

Re:Nanosecond timestamp collisions are common by e12e on Friday July 21, 2023 @07:40PM (#36821520)
> Could maybe be just a mistake when doing the UK registration ? It's an easy fix if wanted.

Changes! lol

Re:Nanosecond timestamp collisions are common by TRiG_Ireland on Monday July 24, 2023 @05:21AM (#36845018)
That's my memory of it. My British passport is expired, and is probably somewhere in my parents' house. I don't actually know what it says on it. I do clearly remember that at least one British form of ID I had at one time recorded my mother's place of residence rather than my actual birth place. I thought it was the passport. Maybe I was wrong.
Re:Nanosecond timestamp collisions are common by dtech on Friday July 21, 2023 @05:54AM (#36811966)
But then you have 2 identifiers which complicates everything.