You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+8-8Lines changed: 8 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,9 +7,9 @@ A PostgreSQL extension that enforces optimal column alignment to minimize row pa
7
7
8
8
## Why Column Order Matters
9
9
10
-
PostgreSQL stores each row as a sequence of bytes on disk. Column types have different sizes — a `bigint` takes 8 bytes, an `integer` takes 4, a `boolean` takes just 1. So far so simple.
10
+
PostgreSQL stores each row as a sequence of bytes on disk. Column types have different sizes: a `bigint` takes 8 bytes, an `integer` takes 4, a `boolean` takes just 1. So far so simple.
11
11
12
-
The problem is that PostgreSQL can't just pack them back to back. The CPU reads memory most efficiently when values are naturally aligned — an 8-byte value should start at a position divisible by 8, a 4-byte value at a position divisible by 4, and so on. To guarantee this, PostgreSQL inserts invisible **padding bytes** between columns whenever needed.
12
+
The problem is that PostgreSQL can't just pack them back to back. The CPU reads memory most efficiently when values are naturally aligned; an 8-byte value should start at a position divisible by 8, a 4-byte value at a position divisible by 4, and so on. To guarantee this, PostgreSQL inserts invisible **padding bytes** between columns whenever needed.
13
13
14
14
Here's an example. Say you create a table like this:
15
15
@@ -43,7 +43,7 @@ CREATE TABLE good_order (
43
43
[user_id: 8B] [age: 4B] [active: 1B] → 13 bytes of column data
44
44
```
45
45
46
-
Zero padding. Same data, 35% smaller rows. Multiply that across millions of rows and dozens of columns — it adds up fast. Optimal column order is free performance: zero runtime cost, just a smarter `CREATE TABLE`.
46
+
Zero padding. Same data, 35% smaller rows. Multiply that across millions of rows and dozens of columns and it will adds up fast. Optimal column order is free performance: zero runtime cost, just a smarter `CREATE TABLE`.
47
47
48
48
### Alignment Groups
49
49
@@ -53,7 +53,7 @@ The extension sorts columns into these groups, largest alignment first:
0 commit comments