Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

text datatype in postgres

 
RamandeepS Singh
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I have to store string of variable lengths in our postgres database.. Strings could be too long
SO can anyone please tell me the pros and crons of the type text(unlimited length), or should i go for some other way to store the string

Thanks
Ramandeep S

 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34422
347
Eclipse IDE Java VI Editor
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This forum uses "text" in postgres to store forum posts. It's similar to the CLOB type in other databases.

The only warning I can think of is that it is good practice to store the text/CLOB type in a table separate from your main data. For example, the jforum_posts table has about 20 columns including a post_id, but not the big field. The jforum_posts_text table has only two columns: post_id and text.

The reason for this is so the database has more rows in each "page" on memory from the main table and can more quickly execute filters (the where clause) against it.
 
Richard Broersma
Ranch Hand
Posts: 63
Firefox Browser Postgres Database Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
PostgreSQL should put large text fields in a Toast table automatically for your.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic