4

I see here that :text data type seems to perform exactly the same as :string

This comment particularly:

PostgreSQL implementation prefers text. The only difference for pg string/text is constraint on length for string. No performance differences.

Is there any good reason to ever use :string when making a rails app using a postgresql database?

1 Answer 1

5

No difference in performance, difference in semantics.

Several libraries (for example simpleform) look at the data type of the field in the database and perform differently depending on it. Simple form will add a number input if it's a number, a checkbox if it's a boolean and so on. For this case, it will add a single line text field for string and a multiline text box for text.

Since there is no difference in performance, you can use either, but it's still useful to denote semantics.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.