?
Solved

Postgres text vs character varying(256) (performance question)

Posted on 2011-03-03
2
Medium Priority
?
1,383 Views
Last Modified: 2012-08-14
Hi Experts,

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)...

Thanks!
Mike
0
Comment
Question by:thready
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 40

Accepted Solution

by:
lcohan earned 2000 total points
ID: 35031157
In order of best perfromance to worse 3,2 and I won't do 1 unless you can't afford the down time to alter your table columns.
0
 
LVL 1

Author Closing Comment

by:thready
ID: 35037065
thanks
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many developers have database experience, but are new to PostgreSQL. It has some truly inspiring capabilities. I have several years' experience with Microsoft's SQL Server. When I began working with MySQL, I wanted a quick-reference to MySQL (htt…
By, Vadim Tkachenko. In this article we’ll look at ClickHouse on its one year anniversary.
Steps to create a PostgreSQL RDS instance in the Amazon cloud. We will cover some of the default settings and show how to connect to the instance once it is up and running.
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Suggested Courses
Course of the Month9 days, 15 hours left to enroll

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question