I'm setting up a Postgres database that will function as a storage place for data records. There's a column in the records that I'm going to be inserting that contains different kinds of data types; floats, integers, and strings. Due to the variety of data types that this column needs to hold, I have set the type of that column to VARCHAR(50), but I fear that this is not very efficient.

Question: As this column will need to hold a lot of values in the future I'm looking for the best way to deal with the different types. What is the best type setting or way of storing these records performance-wise?

up vote 1 down vote accepted

Pretty much that is the definition of a varchar field: a field for various types and lengths, limited only by the max length pretty much. It takes anything a number, a character string, nothing. So what are you going to be doing with it? If it is just storage and you will look at it then does it really matter? If you are going to be doing something else with it, you might need to decide if this is really what you want to do.

Your Answer

 
discard

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.