Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 876925
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T11:31:03+00:00 2026-05-15T11:31:03+00:00

I have a large hexidecimal (16 byte, 32 hex digits) data item that always

  • 0

I have a large hexidecimal (16 byte, 32 hex digits) data item that always has the format:

00d980113901429fa6de7fb7e2da705a

This is coming in as an ASCII string from my source (i.e., the zero above is character zero 0x30, not 0x00), and I would like to know peoples’ opinions on the best way (irt storage and speed) to store this in PostgreSQL.

The obvious thing to do is to just store it as a varchar, but storing it in a binary form would definitely save space. Would I see performance gains from select and insert by storing it in a binary form? Would bytea or bit be better? Is there a difference between these two in terms of internal representation?

Another idea would be to store it as two bigint/int8 or four integer/int4, split up into multiple columns.

Space and time are an issue as I have MANY of these (upwards of a trillion).

  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T11:31:04+00:00Added an answer on May 15, 2026 at 11:31 am

    Compare these two tables of 10M records:

    create table test (a int8 not null, b int8 not null, primary key(a,b));
    insert into test
      select generate_series(1,10000000), generate_series(1,10000000);
    select pg_size_pretty(pg_total_relation_size('test'));
    
    723 MB
    
    create table test_bytea (a bytea not null);
    insert into test_bytea
      select decode(lpad(to_hex(a),16,'0')||lpad(to_hex(b),16,'0'),'hex') from test;
    alter table test_bytea add primary key (a);
    select pg_size_pretty(pg_total_relation_size('test_bytea'));
    
    804 MB
    

    A bytea with index is 11% bigger than 2*int8. This isn’t much, but it means that 11% less rows will be in cache. And sequentional scans will be 11% slower etc.

    If your data does not change maybe you should consider a flat file storage of sorted values instead of database – this will be only 152MB per 10M records and searching will be O(log(n)).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have large chunks of data, normally at around 2000+ entries, but in this
I have large amount of data been passed around in my application as byte[]
We have large files with zlib-compressed binary data that we would like to memory
i have large numbers of text files and i am in problem that i
I have large video files (~100GB) that are local on my machine. I have
Interpolating Large Datasets I have a large data set of about 0.5million records representing
I have large MQ patch applied in Mercurial. What has happened is I have
I have large amounts of data (a few terabytes) and accumulating... They are contained
I have large Boost/Spirit metaprogram that is blowing gcc's stack when I try to
I am developing an application which doesn't have large requirements for data storage. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.