Framinus / pizza-restaurant

An API built in Node, Express and PostgreSQL
0 stars 0 forks source link

Investigate difference between text and varchar fields in SQL. #5

Closed Framinus closed 6 years ago

Framinus commented 6 years ago

Should we change some fields to varchars to make space?

alexandrawaite commented 6 years ago

No difference as far as allocating memory. All the StackOverflow answers and blogs agree: As "Character Types" in the documentation points out, varchar(n), char(n), and text are all stored the same way. The only advantage of specifying the length specifier for the varchar data type is that PostgreSQL will check and issue an error if you try to insert a longer string into the varchar(n) column. It's problematic to change the limit of varchar(n) in live environment.

I think text is perfectly fine for this project.