Data Type Sizes

System Design

A table of data type sizes in Postgres, useful for back-of-the-envelope calculations. The values will differ for different database systems, but the relative sizes will be similar. Squares are scaled in size logarithmically.

TypePostgres Data TypesSizeNotes
Integer
  • SMALLINT: 2 bytes
  • INTEGER: 4 bytes
  • BIGINT: 8 bytes
2 bytes
4 bytes
8 bytes
Used for numeric fields, IDs, and counters. Larger sizes support larger ranges.
Floating Point
  • REAL: 4 bytes
  • DOUBLE PRECISION: 8 bytes
4 bytes
8 bytes
Used for scientific calculations or approximate values.
Timestamp
  • TIMESTAMP: Without timezone
  • TIMESTAMPTZ: With timezone
8 bytes
Used for date and time fields, with or without timezone information.
UUID
  • UUID: 16 bytes
16 bytes
Universally unique identifiers for distributed systems.
Enum
  • ENUM: 1-4 bytes
1 byte
4 bytes
  • Represents a predefined set of values.
  • Examples: User roles, statuses, or category lists.
String
  • VARCHAR(n): Up to n characters
  • TEXT: Unlimited length
~100 bytes
~1 KB
~10 KB
  • Short: Usernames, titles, or short sentences.
  • Medium: Descriptions or paragraphs of text.
  • Long: Articles, blog posts, or large text fields.
JSONB
  • JSONB: Variable length
~100 bytes
~1 KB
~10 KB
  • Small: Simple JSON objects.
  • Medium: Nested JSON or API responses.
  • Large: Complex JSON with many fields.
BYTEA
  • BYTEA: Variable length
~1 KB
~100 KB
~1 MB
  • Small: Icons or thumbnails.
  • Medium: Profile pictures or compressed files.
  • Large: High-resolution images or large documents.
Legend:
1 byte
100 bytes
1 KB (1,024 bytes)
10 KB
100 KB
1 MB (1,048,576 bytes)