Doing the Math on How Much Space a Small Table Takes
When you build your first app, it is natural to wonder whether your data will "fit". For most learning projects the honest answer is: easily. This page shows a rough way to estimate table size so the question stops being a worry and becomes a small sum.
Bytes, briefly
Computers measure storage in bytes. A thousand bytes is about a kilobyte (KB), a million is about a megabyte (MB), and a billion is about a gigabyte (GB). A short line of plain English text is a few dozen bytes.
Step 1: add up the columns
Each column type takes a typical amount of space. The figures below are rough guides for common types; exact sizes depend on the database.
| Column type | Rough size per value |
|---|---|
| Small whole number (INTEGER) | about 4 bytes |
| Big whole number (BIGINT) | about 8 bytes |
| Date and time (TIMESTAMP) | about 8 bytes |
| True or false (BOOLEAN) | about 1 byte |
| Text (VARCHAR / TEXT) | about one byte per plain English letter, plus a little extra |
Imagine a notes table for a study app:
idBIGINT: 8 bytescreated_atTIMESTAMP: 8 bytestitletext, around 40 letters: about 40 bytesbodytext, around 400 letters: about 400 bytes
That is roughly 456 bytes per row.
Step 2: multiply by the number of rows
If you expect 10,000 notes:
456 bytes × 10,000 rows = 4,560,000 bytes ≈ 4.6 MB
Under five megabytes. A phone photo is often bigger than that.
Step 3: add some extra
Real files are always larger than the simple sum, because a database also stores:
- a small header for every row
- spare room inside pages so rows can grow
- indexes, which are extra lookup structures, at least one for the primary key
A safe beginner habit is to double your estimate. So call it around 10 MB. Still tiny.
Checking the real number
Once your table has data, ask the database itself:
-- SQLite: the whole database is one file; check its size in your file manager
-- PostgreSQL
SELECT pg_size_pretty(pg_total_relation_size('notes'));
-- MySQL
SELECT table_name, data_length + index_length AS bytes
FROM information_schema.tables
WHERE table_name = 'notes';
Comparing your estimate with the real figure is a nice way to learn how your database stores things.
What makes tables big
- Large text or files stored in the table. Photos and PDFs are usually better kept as files, with only their name or address saved in the database.
- Many rows. Logs and events grow fast because a new row is added every time something happens.
- Many indexes. Each one is another copy of some columns.
The takeaway
For a learning project or a first small app, storage is almost never the problem. Spend your energy on clear table design and safe queries instead; the space will take care of itself.
A free learning page for beginners. Practise on a test database, never on real customer data, and check the official documentation for your database version.