Discussion summary
The discussion covers strategies for database partitioning and handling large datasets, mentioning tools like kdb+, Snowflake ID, UUID7, and ClickHouse. Different approaches to primary key design and indexing in PostgreSQL and MySQL are also debated.
What the discussion says
- Using kdb+ for high-volume data ingestion is effective.
- Snowflake ID and UUID7 are recommended for distributed IDs.
- ClickHouse is suitable for daily data warehousing.
- Partitioning by auto-incremented ID can be beneficial.
“kdb+ handles 1bn rows a day easily.”
“Snowflake ID patterns translate well to UUID7.”
Comments
Hacker News
by leprechaun1066
by piterrro
by khurs
by djfobbz
That is why columnar DBs, not matter how impressive, are not used by OLTP workloads (and here this article point you can undo the advantages without pay attention at the consequences of partitions).
by mamcx
The application probably still treats id as unique, but nothing in the schema guarantees it. And you can’t recover the guarantee with a separate UNIQUE (id) constraint: both MySQL and PostgreSQL require every unique constraint on a partitioned table to include the partition key columns. The uniqueness property has effectively been traded away.
Not really?MySQL has AUTO_INCREMENT [1]
PostgreSQL has SERIAL [2] and CREATE SEQUENCE [3]
What am I missing?
[1] https://dev.mysql.com/doc/refman/8.4/en/example-auto-increme...
[2] https://www.postgresql.org/docs/18/datatype-numeric.html#DAT...
[3] https://www.postgresql.org/docs/18/sql-createsequence.html
by Insimwytim
> The primary key already exists. For tables using BIGINT AUTO_INCREMENT, it’s monotonically increasing: newer rows have larger IDs. That’s the property range partitioning needs. The primary key is the partition key.
by toledocavani
by yasaheblasa
by jagged-chisel
You “search” for a record (perhaps based on username [and then you verify the password hash, but I digress]) and now you know the ID. Carry the ID in a session (the app doesn’t display this) and you can modify this specific user’s record. This is especially useful if you allow editing fields on which searches happen. Want to change a username? Great, you can.
If the username is your primary key, and you allow users to change them, there are edge cases and nuances and headaches … just use something immutable to identify records - autoincremented int, UUID, etc
by jagged-chisel
Join the discussion
Write your take first — we'll ask for email only when you're ready to publish.
- Hacker News
- Or just use kdb+ and 1bn rows a day is par for the course.by leprechaun1066
- For anyone interested in the topic I suggest reading about snowflake id [https://en.wikipedia.org/wiki/Snowflake_ID] or uuid7 the patterns from the article translate cleanly. The bigint is 64 bytes where uuid is 128. There are other caveats but its all about tradeoffs.by piterrro
- Technically - as Postgresql stores the UUID data type as binary, it's 16 bytes.by khurs
- Or you could just warehouse the daily data into something like ClickHouse and start fresh every day. It's built for this kind of workload and has demonstrated some absolutely insane analytical performance at massive scale. We're currently running it on an $170/month VPS, querying over 500+ billion rows daily without any issues. At that point, partitioning an ever-growing OLTP table starts looking like the harder problem.by djfobbz
- With the other comment about kdb+ and this show a misread of the article: The article AND ANY use of a columnar DB show the same issue: Point lookups are badly pessimized with both partitions on other columns and/or columnar.
That is why columnar DBs, not matter how impressive, are not used by OLTP workloads (and here this article point you can undo the advantages without pay attention at the consequences of partitions).
by mamcx
Not really?The application probably still treats id as unique, but nothing in the schema guarantees it. And you can’t recover the guarantee with a separate UNIQUE (id) constraint: both MySQL and PostgreSQL require every unique constraint on a partitioned table to include the partition key columns. The uniqueness property has effectively been traded away.MySQL has AUTO_INCREMENT [1]
PostgreSQL has SERIAL [2] and CREATE SEQUENCE [3]
What am I missing?
[1] https://dev.mysql.com/doc/refman/8.4/en/example-auto-increme...
[2] https://www.postgresql.org/docs/18/datatype-numeric.html#DAT...
[3] https://www.postgresql.org/docs/18/sql-createsequence.html
by Insimwytim- And the post did mention it, argueing it may be better to partition by auto-incremented ID with the support of catch-all range and partution monitoring.
> The primary key already exists. For tables using BIGINT AUTO_INCREMENT, it’s monotonically increasing: newer rows have larger IDs. That’s the property range partitioning needs. The primary key is the partition key.
by toledocavani - This is a topic that interests me a lot but there's a lot I find surprising since I finally started working with postgres dependent apps. Why for example is the id a good primary key? Joins are not uncommon, but I don't have anyone searching on id in my application and it is not even supposed to be user visible. I would think every possible user search would look at all partitions indexes if I did this instead of creation date.by yasaheblasa
- Your primary key is there to uniquely identify a record. You need additional indexes on fields you will search on.by jagged-chisel
- Allow me to clarify a bit more.
You “search” for a record (perhaps based on username [and then you verify the password hash, but I digress]) and now you know the ID. Carry the ID in a session (the app doesn’t display this) and you can modify this specific user’s record. This is especially useful if you allow editing fields on which searches happen. Want to change a username? Great, you can.
If the username is your primary key, and you allow users to change them, there are edge cases and nuances and headaches … just use something immutable to identify records - autoincremented int, UUID, etc
by jagged-chisel
Related stories
Decoding the obfuscated bash script on a Uniqlo t-shirt
tris.sherliker.net · 1072 points · 181 comments
StreetComplete: Fixing OpenStreetMap, one tiny quest at a time
streetcomplete.app · 761 points · 182 comments
Every new car sold in the European Union must include a driver monitoring camera
allaboutcookies.org · 737 points · 969 comments
Chat Control 1.0 and 2.0 Explained
fightchatcontrol.eu · 645 points · 238 comments
Microsoft fire idTech team at Id software
gamefromscratch.com · 597 points · 533 comments
Chat Control passed first round in EU Parliament
heise.de · 567 points · 246 comments