From: Tom Lane <tgl@sss.pgh.pa.us>
To: Thomas Kellerer <shammat@gmx.net>
Cc: Postgres General <pgsql-general@postgresql.org>
Subject: Re: Does TOAST really compress the complete row?
Date: Thu, 02 Jul 2020 18:15:50 -0400
Message-ID: <890934.1593728150@sss.pgh.pa.us> (raw)
In-Reply-To: <ec56843a-dd32-ed81-872d-f10247c8a7e0@gmx.net>
References: <ec56843a-dd32-ed81-872d-f10247c8a7e0@gmx.net>
Thomas Kellerer <shammat@gmx.net> writes:
> I am confused about one claim in this blog post: https://www.2ndquadrant.com/en/blog/oracle-to-postgresql-binary-objects>> All columns that come after data > 2000 bytes participate in The
>> Large Attribute Strorage Technique (TOAST). This storage is for the
>> row, not the column. Your id column comes as the last column in the
>> table? Whoopsie, your primary key just got shoved into blob storage
> I always was under the impression that TOASTing only happens on column level, not on row level.
You're right, and the quoted text is wrong. Not only does TOAST compress
fields not whole rows, but it selectively targets wider fields first.
If your pkey is getting toasted, you should likely rethink your choice
of pkey. (Or, possibly, you just have so many fields there's no choice
but to compress all of them. Then it might be time for a table redesign.)
The decision-making about this is concentrated in
heap_toast_insert_or_update, which can be seen here:
https://git.postgresql.org/gitweb/?p=postgresql.git;a=blob;f=src/backend/access/heap/heaptoast.c
regards, tom lane
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: tgl@sss.pgh.pa.us, shammat@gmx.net
Subject: Re: Does TOAST really compress the complete row?
In-Reply-To: <890934.1593728150@sss.pgh.pa.us>
References: <ec56843a-dd32-ed81-872d-f10247c8a7e0@gmx.net> <890934.1593728150@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox