7 ms·
Doesn't the use of check constraints add an overhead and possibly negate the slight performance advantage that was gained by using text instead of varchar/char?
by srisa 13y ago
Doesn't the use of check constraints add an overhead and possibly negate the slight performance advantage that was gained by using text instead of varchar/char?
- ddebernardy 13y agoYeah. Technically, `foo varchar(n)` amounts to syntactic sugar for `foo varchar check(length(foo) <= n)`. What the benchmarks show, if anything, is that while the `check` involves negligible overhead per row, the overhead can eventually be enough to make a measurable difference. Not to mention, the Postgres actually manual says as much as the above, in its description of text types.
- epo 13y agoThe check constraint should only be applied when the column is updated so depends on your usage.