Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes JDBC and the fly likes text datatype in postgres Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "text datatype in postgres" Watch "text datatype in postgres" New topic
Author

text datatype in postgres

RamandeepS Singh
Ranch Hand

Joined: Aug 25, 2009
Posts: 63
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
internet detective
Marshal

Joined: May 26, 2003
Posts: 30512
    
150

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.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Richard Broersma
Ranch Hand

Joined: Apr 28, 2009
Posts: 63

PostgreSQL should put large text fields in a Toast table automatically for your.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: text datatype in postgres