Data Type Best Practices
pgfence catches common type choices that will cause problems down the line.
| # | Pattern | Risk | Suggestion |
|---|---|---|---|
| 20 | ADD COLUMN ... json | LOW | Use jsonb: json has no equality operator and is generally slower |
| 21 | ADD COLUMN ... serial | LOW | Use GENERATED BY DEFAULT AS IDENTITY: SERIAL creates implicit sequences with ownership quirks and permission issues |
| 22 | integer / int columns | LOW | Use bigint: changing to bigint later requires an ACCESS EXCLUSIVE rewrite |
| 23 | varchar(N) columns | LOW | Use text: increasing varchar length requires ACCESS EXCLUSIVE on older Postgres versions |
| 24 | timestamp without time zone | LOW | Use timestamptz to avoid timezone-related bugs |
| 25 | char(N) / character(N) columns | LOW | Use text: char(n) pads values with spaces, wastes storage, and changing the length later requires ACCESS EXCLUSIVE + table rewrite |
| 26 | serial / bigserial / smallserial columns | LOW | Use GENERATED BY DEFAULT AS IDENTITY: IDENTITY columns have cleaner ownership semantics, avoid implicit sequence permission issues, and are the SQL standard |