They also are ActivityPub objects that expand to the full id ✨
-
RE: https://mastodon.social/@dansup/115876278291815667
They also are ActivityPub objects that expand to the full id ✨
We use snowflake ids, then hashids in permalinks that expand. It's beautifully simple, yet clever.
d9VqOD2_gu => 236972985113375774
https://browser.pub/https://loops.video/v/d86zgftFT9?rid=d9VqOD2_gu
-
RE: https://mastodon.social/@dansup/115876278291815667
They also are ActivityPub objects that expand to the full id ✨
We use snowflake ids, then hashids in permalinks that expand. It's beautifully simple, yet clever.
d9VqOD2_gu => 236972985113375774
https://browser.pub/https://loops.video/v/d86zgftFT9?rid=d9VqOD2_gu
@dansup I don't understand why do you have to convert the alphanumeric string to just numbers though?
-
@dansup I don't understand why do you have to convert the alphanumeric string to just numbers though?
@bojanlandekic the long numbers are the keys to each video, but are long, so we convert them to a shorter alphanumeric string by leveraging a longer "alphabet" to represent the numbers more efficiently.
-
@bojanlandekic the long numbers are the keys to each video, but are long, so we convert them to a shorter alphanumeric string by leveraging a longer "alphabet" to represent the numbers more efficiently.
@dansup hmmm I sort of understand, but why is the conversion even required? Why can't the alphanumeric things be the database keys themselves? Why must they be just numbers?
-
@dansup hmmm I sort of understand, but why is the conversion even required? Why can't the alphanumeric things be the database keys themselves? Why must they be just numbers?
@bojanlandekic@mastodon.social short answer is: snowflake IDs have a time-component to them, making them friendly for sharding and indexing. If you compress that into an alphanumeric string, you most likely loose the efficiency benefits. It's kinda like why you might see UUID primary keys not being recommended, when the standard UUID was UUIDv4 which had poor index & sharding efficiency, but with the newer UUIDv7, which are time sortable, you gain back that efficiency.
Basically randomness is the enemy of database performance, having stuff ordered by time in the primary key makes it easy for the database to know which pages of the database to look at, and which to ignore, as page files are created over time.