Alex Rivera | Logout

Difference between string and text in rails?

Asked 2010-07-28T15:15:33.407
486

I'm making a new web app using Rails, and was wondering, what's the difference between string and text? And when should each be used?

Edit
Report

1 Answer

180

If you are using postgres use text wherever you can, unless you have a size constraint since there is no performance penalty for text vs varchar

There is no performance difference among these three types, apart from increased storage space when using the blank-padded type, and a few extra CPU cycles to check the length when storing into a length-constrained column. While character(n) has performance advantages in some other database systems, there is no such advantage in PostgreSQL; in fact character(n) is usually the slowest of the three because of its additional storage costs. In most situations text or character varying should be used instead

PostsgreSQL manual

answered 2010-07-28T15:53:17.510

Your Answer