It’s mostly about reading speed — but let’s break it down:
Why is CHAR
Sometimes Faster Than VARCHAR
?
- Fixed Size = Simple Calculations
CHAR(n)
always stores exactlyn
characters.- The database can easily calculate: “Where is the 10th record? Just jump
n × 10
bytes.”
✅ Fast offset calculation — no need to scan row lengths.
- No Extra Metadata
VARCHAR(n)
stores variable-length data.- It needs extra storage for length information — 1 or 2 bytes per field.
- Every time you read, the database must: “First check how long the value is, then read it.”
✅ With CHAR
, it just reads a fixed block — no lookup needed.
- Row Alignment and Memory Access
- In memory (RAM), fixed-length rows are easier to align and read.
- CPUs love aligned data — it’s faster to load into cache.
✅ CHAR
rows can be packed into aligned memory blocks — speeding up sequential reading.
So in short:
CHAR (Fixed) | VARCHAR (Variable) |
---|---|
Fixed size — faster memory access | Variable size — slower memory jumps |
No need to check length | Need to check length each time |
Simple math for row offsets | Complex row parsing |
Slightly faster reads in large datasets | Slightly slower reads |
Is It Also Faster for Writing?
❌ No — not faster for writing:
- In fact,
CHAR
wastes space — even if you only store 2 characters inCHAR(100)
, it still reserves space for all 100 characters. - More disk I/O (because bigger rows).
- Longer writes for small values.
✅ VARCHAR
is better for writing:
- It stores only the bytes needed.
- More storage efficient — smaller rows = faster disk writes.
So Final Answer:
Operation | Which is Faster? | Why? |
---|---|---|
Read (Sequential Reads) | CHAR (small advantage) | Fixed length, faster offsets, no length checking. |
Write (Insert/Update) | VARCHAR | Smaller storage, less disk I/O, more efficient space use. |
When Does This Matter?
- In very large tables (millions of rows).
- In high-performance analytics or data warehouses.
- When you need extremely predictable row size (like in OLTP banks, telecoms).
Otherwise — for most apps (web, mobile) — VARCHAR
is better for storage efficiency and flexibility.
In Short
CHAR
can be slightly faster for reading large datasets because of fixed length, but it wastes space and is not faster for writing.