Reputation: 6315
I do not understand when to use the different lengths for calling unicode. I have been using types.Unicode(255) for all my columns in my postgres database such as address, name, description, etc. Is it unwise to do this?
Upvotes: 3
Views: 2541
Reputation: 1161
It's worth adding to depesz's answer that there are no performance penalties for using text type rather than varchar(n) or char(n) data types, so unless you need to set a hard limit for business purposes just use text. Even then, use text with a length constraint :-)
Upvotes: 2
Reputation:
Not sure what you mean by "unicode(255)" - there is no such data type in PostgreSQL:
# create table q (x unicode(255));
ERROR: type "unicode" does not exist
LINE 1: create table q (x unicode(255));
^
Maybe you meant varchar(255). In this case - let me ask: what will happen if you'll need 320 character description?
Personally I prefer to use TEXT datatype - since database generally doesn't care if the string is 100 or 1000 characters long.
Upvotes: 4
Reputation:
There are a number of reasons to use proper datatypes in your databases. Performance (pdf) is the biggest concern, but there are other reasons too. For example:
Upvotes: -1