3 ms·
> typically in PostgreSQL you just use text type and not impose any length restrictions unless absolutely necessary. There was a horror story posted on here a
by pphysch 4y ago
> typically in PostgreSQL you just use text type and not impose any length restrictions unless absolutely necessary.
There was a horror story posted on here a while back about some old API causing an outage because there happened to be a random text field that a user was effectively using as an S3 bucket. Their conclusion was to always set a sane length constraint (even if very large, say 1MiB for the smallest fields) on field sizes.
Hyrum's Law. Yes user input validation, blah blah, but that is infinitely more surface area than having a sane (or absurdly large) limit by default.
- jeffdn 4y agoRight, but use a check constraint and not a data type constraint (i.e. `varchar(x)`). That sounds more like a code review issue -- `blob` would've been an appropriate storage type in that case.
- Pv9KKy3 4y agoI use and prefer varchar(1000) personally, extremely easy to change in the future if needed.
- pphysch 4y ago> That sounds more like a code review issue -- `blob` would've been an appropriate storage type in that case. No, it was supposed to be a short text field. Not an infinite storage endpoint!