Hacker News new | ask | show | jobs
by srisa 4589 days 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?
2 comments

Yeah. 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.

The check constraint should only be applied when the column is updated so depends on your usage.