Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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?


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.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: