PostgreSQL Table Optimizer
Optimize your table column ordering to minimize padding..
Paste your CREATE TABLE statement or the output of \d <YOUR_TABLE> and see the optimized version instantly.
Alignment must be: Char, Short, Int, or Double
Click "Optimize Table" to see the optimized version of your SQL statement.
Memory Layout Visualization
Original Layout
Total: 0 bytesPadding: 0 bytes
8-byte aligned (Double)
4-byte aligned (Int)
2-byte aligned (Short)
1-byte aligned (Char)
Padding bytes
Optimized Layout
Total: 0 bytesPadding: 0 bytes
8-byte aligned (Double)
4-byte aligned (Int)
2-byte aligned (Short)
1-byte aligned (Char)
Padding bytes
How It Works
PostgreSQL Alignment Rules
- Char - 1 byte alignment (boolean, char)
- Short - 2 byte alignment (smallint)
- Int - 4 byte alignment (integer, date)
- Double - 8 byte alignment (bigint, timestamp)
Optimization Strategy
- • Order columns by alignment requirement (largest first)
- • Group same-sized columns together
- • Minimize padding bytes between columns
- • Preserve column constraints and properties