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 8083561
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T17:30:42+00:00 2026-06-05T17:30:42+00:00

I’m going to store records in a single table with 2 fields: id ->

  • 0

I’m going to store records in a single table with 2 fields:

  • id -> 4 characters

  • password_hash -> 64 characters

How many records like the one above will I be able to store in a 5mb PostgreSQL on Heroku?

P.S.: given a single table with x columns and a length of y – how can I calculate the space it will take in a database?

  • 1 1 Answer
  • 0 Views
  • 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-06-05T17:30:45+00:00Added an answer on June 5, 2026 at 5:30 pm

    Disk space occupied

    Calculating the space on disk is not trivial. You have to take into account:

    • The overhead per table. Small, basically the entries in the system catalog.

    • The overhead per row (HeapTupleHeader) and per data page (PageHeaderData). Details about page layout in the manual.

    • Space lost to column alignment, depending on data types.

    • Space for a NULL bitmap. Effectively free for tables of 8 columns or less, irrelevant for your case.

    • Dead rows after UPDATE / DELETE. (Until the space is eventually vacuumed and reused.)

    • Size of index(es). You’ll have a primary key, right? Index size is similar to that of a table with just the indexed columns and less overhead per row.

    • The actual space requirement of the data, depending on respective data types. Details for character types (incl. fixed length types) in the manual:

      The storage requirement for a short string (up to 126 bytes) is 1 byte
      plus the actual string, which includes the space padding in the case
      of character. Longer strings have 4 bytes of overhead instead of 1

      More details for all types in the system catalog pg_type.

    • The database encoding in particular for character types. UTF-8 uses up to four bytes to store one character (But 7-Bit-ASCII characters always occupy just one byte, even in UTF-8.)

    • Other small things that may affect your case, like TOAST – which should not affect you with 64-character strings.

    Calculate with test case

    A simple method to find an estimate is to create a test table, fill it with dummy data and measure with database object size functions::

    SELECT pg_size_pretty(pg_relation_size('tbl'));
    

    Including indexes:

    SELECT pg_size_pretty(pg_total_relation_size('tbl'));
    

    See:

    • Measure the size of a PostgreSQL table row

    A quick test shows the following results:

    CREATE TABLE test(a text, b text);
    INSERT INTO test -- quick fake of matching rows
    SELECT chr((g/1000 +32)) || to_char(g%1000, 'FM000')
         , repeat (chr(g%120 + 32), 64)
    FROM   generate_series(1,50000) g;
    
    SELECT pg_size_pretty(pg_relation_size('test'));       -- 5640 kB
    SELECT pg_size_pretty(pg_total_relation_size('test')); -- 5648 kB
    

    After adding a primary key:

    ALTER TABLE test ADD CONSTRAINT test_pkey PRIMARY KEY(a);
    
    SELECT pg_size_pretty(pg_total_relation_size('test')); -- 6760 kB
    

    So, I’d expect a maximum of around 44k rows without and around 36k rows with primary key.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I need a function that will clean a strings' special characters. I do NOT
I would like to count the length of a string with PHP. The string
For some reason, after submitting a string like this Jack’s Spindle from a text
I've got a string that has curly quotes in it. I'd like to replace
I am reading a book about Javascript and jQuery and using one of the
I am trying to render a haml file in a javascript response like so:
I would like to run a str_replace or preg_replace which looks for certain words

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.