GithubHelp home page GithubHelp logo

Comments (2)

erizocosmico avatar erizocosmico commented on August 18, 2024

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.

joelvh avatar joelvh commented on August 18, 2024

@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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.