Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PostgreSQL Big Text Column Performance

I am storing sent emails in a RDBMS including the to address, from address, and email body.

The body can really be any arbitrary amount of text, and I won't ever care to search on it.

Are there any performance issues I should worry about when having a potentially large column that isn't used too often in one of my most frequently accessed tables (Emails) ?

(This project is written in Rails)

like image 453
Thomas Tremble Avatar asked Sep 05 '11 16:09

Thomas Tremble


People also ask

How do I store large text in PostgreSQL?

Option One: use LOB storage. In relational databases, a particular data type exists to store big amounts of data: LOB (Large OBject). Once we need to store large text in the database, we can start with defining a LOB column. All we need to do is mark the docText attribute with the @Lob annotation.

Is PostgreSQL good for full text search?

Yes, You Can Keep Full-Text Search in Postgres You can get even deeper and make your Postgres full-text search even more robust, by implementing features such as highlighting results, or writing your own custom dictionaries or functions.

What is maximum size of text data type in Postgres?

What is PostgreSQL Text datatype? In PostgreSQL, the text data type is used to keep the character of infinite length. And the text data type can hold a string with a maximum length of 65,535 bytes.

Is Postgres good for large data?

You should have no problem using Postgres for reporting and analytics. Postgres generally provides fast and stable query performance and can quickly access up to a terabyte on a single instance. On the flipside, if you have a smaller (or growing) team in need of big data insights, Postgres isn't a cure-all.


2 Answers

postgresql stores large objects in a secondary area. You can read about it here: TOAST. The main concern will be keeping the large object out of the select list of queries that return many rows, so that you avoid visiting the secondary storage area.

If and when you do decide to add search functionality to the body text, you will need to use a full text strategy, which is well supported in Postgres, but is somewhat non intuitive. The topic receives a full chapter of treatment in the manual.

like image 87
SingleNegationElimination Avatar answered Sep 20 '22 15:09

SingleNegationElimination


No, you don't need to worry about that.

Technically there is no difference in storage between a e.g. varchar(5) and a text column.

Quote from the manual

there is no performance difference among these three types, apart from increased storage space when using the blank-padded type

The three types mentioned there are char, varchar and text. Where char is the "blank-padded type".

like image 23
a_horse_with_no_name Avatar answered Sep 19 '22 15:09

a_horse_with_no_name