Comments (2)
Using ULID would require us to use CHAR(26)
or TEXT
instead of UUID
, which is almost twice the size as an uuid
column.
So, even if we used an uuid as primary key and a created_at
(which is a column that we will have anyway and most of the tables will already have an index there to search by that) as sorting index, the size of both columns would be smaller than a single ULID column (16+8 < 30)
select pg_column_size('01AN4Z07BY79KA1307SR9X4MV3'::text) as text_size,
pg_column_size('110ec58a-a0f2-4ac4-8393-c866d813b8d1'::uuid) as uuid_size,
pg_column_size('01AN4Z07BY79KA1307SR9X4MV3'::char(26)) as char_size,
pg_column_size(current_timestamp::timestamptz) as timestamp_size;
text_size | uuid_size | char_size | timestamp_size
-----------+-----------+-----------+----------------
30 | 16 | 30 | 8
I can do some research to check which option would have bigger indexes, but my guess is that it will probably still be smaller.
from go-kallax.
@erizocosmico curious what you did here. We are starting to use PostgreSQL UUID and are looking to store ULID in there. What we do is decode the ULID to integer, then integer to hex, and then we pad it with zeros (usually one zero) to get to the proper UUID length.
What are your thoughts or what did you do?
from go-kallax.
Related Issues (20)
- Quote field and table name HOT 4
- Swap out satori/go.uuid for gofrs/uuid HOT 1
- Filter based on related tables' columns not working HOT 1
- Foreign key in embedded struct HOT 1
- Create indexes HOT 1
- Сompose types from different packages
- go 1.11 mod support HOT 12
- Current status of Kallax HOT 2
- []byte fields get overwritten with random data when updating a model HOT 5
- Models do not generate using github.com/gofrs/uuid HOT 3
- model not generating with oauth2 package
- The name kallax HOT 3
- Models do not generate columns with "_\d" HOT 1
- Don't use github url when importing go-kallax HOT 2
- Any support for "FOR UPDATE"?
- Limit and Offset in 1:N Relationship
- New tagged release with latest fixes HOT 9
- Deprecated?
- Set transaction isolation level
- What is the status of this project? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from go-kallax.