News for hackers. Stuff that matters.
Re:Postgres: Boundless `Text` and Back Again by tyingq on Friday September 10, 2021 @02:36PM (#28485481)
>varchar(200) for shorter-length strings like names, addresses, email addresses, etc...The idea is to pick liberal numbers that are easily long enough

I'm not convinced 200 is liberal enough for some of that.

For email, a 64 character local part is RFC compliant, then 1 for the '@', and the domain can be 253 characters.

Probably similar edge cases for addresses.

Re:Postgres: Boundless `Text` and Back Again by marsdepinski on Friday September 10, 2021 @03:22PM (#28485947)
Max length of email address is 254 per the email address RFC. https://www.rfc-editor.org/errata_search.php?rfc=3696
Re:Postgres: Boundless `Text` and Back Again by skybrian on Friday September 10, 2021 @07:53PM (#28488168)
On the other hand, 200 characters is already so long that it might not render correctly, particularly on mobile.
Re:Postgres: Boundless `Text` and Back Again by tragomaskhalos on Friday September 10, 2021 @04:37PM (#28486602)
Yes in fact in many domains there are standards that can be ransacked for appropriate domain sizes. The problem is that it's a chore to dig these out, data architects would sooner just guess some numbers.
Re:Postgres: Boundless `Text` and Back Again by brandur on Friday September 10, 2021 @02:38PM (#28485502)
I note pretty explicitly in there that you should pick your own numbers.

The idea I was trying to get across is that of order of magnitude tiers so that you don't end up with VARCHARs of a hundred random lengths.

Re:Postgres: Boundless `Text` and Back Again by tyingq on Friday September 10, 2021 @02:41PM (#28485525)
Sure. People just tend to grab stuff from articles written by people with your depth of expertise, so I thought it was worth noting.
Re:Postgres: Boundless `Text` and Back Again by brandur on Friday September 10, 2021 @02:55PM (#28485689)
Yeah, you'd need a longer field for maximum correctness for sure. Reminds me of the RFC 822 regex for validating an email address [1] (clocking in at a full page, although now there are simpler ones you can use).

I tend to think that there is a point where you trade off some correctness for pragmatism. It is true that you could have a user with a 250 character email address, but in a lot of years I've never really seen a legitimate one, and the likelihood is that if you do see one then it's someone doing something weird as opposed to a legitimate customer.

Email is actually one that you might want to just leave as `TEXT` and make sure you're validating with a package, which is something you might want to do anyway. However, I still think it serves as a useful example because most people have a good feel for about how long an email address is.

---

[1] http://www.ex-parrot.com/~pdw/Mail-RFC822-Address.html