Hacker News new | past | comments | ask | show | jobs | submit login

Episode suggestion: VARCHAR vs TEXT



Pretty easy to get just from reading the first couple paragraphs of the documentation. Postgres has three string types, CHARACTER, CHARACTER VARYING, and TEXT.

CHARACTER VARYING is the basic type of string, and can be given with a maximum character length. If no length is given, the max value is assumed.

CHARACTER is a padded string - all strings are padded to the specified length with spaces. If no length is given, the length 1 is assumed.

TEXT is an alias for a CHARACTER VARYING without a length parameter (max length).

Actually all string types are handled the same internally, and there's no performance reason to use CHARACTER instead of CHARACTER VARYING. In fact it may hurt performance since the padding increases the data size. Using length constraints also carries a slight performance hit during writes as the constraint gets checked.

https://www.postgresql.org/docs/9.5/static/datatype-characte...




Join us for AI Startup School this June 16-17 in San Francisco!

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

Search: