When creating migrations via libraries like Rails or Ecto it’s common to use string for a column type (which maps to varchar(255)). Today I reminded myself that with PostgreSQL it’s better to use text instead. It turns out text is just as efficient and saves you from having to deal with changing varchar(n) lengths should the time ever come. Should you want to limit the length of a text column, there are options.

For an analysis including benchmarks see CHAR(X) VS. VARCHAR(X) VS. VARCHAR VS. TEXT.