P
P
Pavel2016-07-10 22:44:27
PostgreSQL
Pavel, 2016-07-10 22:44:27

PostgreSQL, does it make sense to move a large column to a separate table?

There is a table with goods which contains about 50 million records, the size is about 100Gb. Postgres caches lines in RAM the first time it reads lines from disk to speed up lookups.

CREATE TABLE product (
  id BIGINT PRIMARY KEY,
  ...
  description TEXT,
);

Does it make sense to move the description field to a separate table so that description is not cached in memory, thereby freeing up memory and speeding up work with goods?
I read about TOAST, but I still don’t understand, description will be loaded into memory if only id is specified in SELECT.
SELECT id FROM product LIMIT 10;
PostgreSQL 9.5

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
lega, 2016-07-11
@lega

The TEXT type is not stored in the table anyway, a link to it is stored. (although small sizes are sometimes stored directly in the table, implementation dependent)
Postgres should not clog memory with this. And if you separate it into the second column, then you will waste on an additional index.
This makes sense if your description is repeated for different products, as a result you can use the same description (one line) for different products.
To speed up, you need to see what queries and indexes you have.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question