Postgres text vs character varying(256) (performance question)
Posted on 2011-03-03
I'm wondering what kind of performance hit I'm going to take with queries if I use the text type rather than character varying. I have a table that stores my data with each field in a record in a row, rather than in its own column. There are about 500 fields per record (sparsely filled in). I identify the type of data with a type column and depending on the type, it's either an int, double or text. That text is too short in some cases (for note fields). I can think of 3 choices I have (or please tell me if there's something I'm not thinking of!)
1- Add a text column (in addition to the character varying column). For most rows, it will be null
2- Change the character varying column to a text column. All 500 or so fields will be of type text instead of most as character varying and some text. (note that both columns are always on every row anyway).
3- Add a whole new table for fields of type text (I know this is probably the best, but I really don't want to do this)...