Are there any optimization benefits (storage/query speed/...) of choosing specific lengths for VARCHAR columns in PostgreSQL? Like, 2^n-1 or something similar?
Asked
Active
Viewed 53 times
0
xaxa
- 111
- 2
1 Answers
2
No. The “type modifier” (value in parentheses) for character varying is just an extra length limit check, and there are no magic numbers that improve performance.
If you want to save a minuscule bit of performance, use text instead. The implementation is the same as for character varying, and skipping the length check will save a few instructions.
Laurenz Albe
- 61,070
- 4
- 55
- 90