pg.ddx.io pgsql-general@postgresql.org mailing list archive
help / color / mirror / Atom feedDoes TOAST really compress the complete row?
5+ messages / 4 participants
[nested] [flat]
* Does TOAST really compress the complete row?
@ 2020-07-02 22:00 Thomas Kellerer <shammat@gmx.net>
2020-07-02 22:15 ` Re: Does TOAST really compress the complete row? Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 1 reply; 5+ messages in thread
From: Thomas Kellerer @ 2020-07-02 22:00 UTC (permalink / raw)
To: pgsql-general
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.
The manual does not mention anything about the whole row being TOASTed if one column exceeds the threshold.
Can someone clarify please?
Thomas
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: Does TOAST really compress the complete row?
2020-07-02 22:00 Does TOAST really compress the complete row? Thomas Kellerer <shammat@gmx.net>
@ 2020-07-02 22:15 ` Tom Lane <tgl@sss.pgh.pa.us>
2020-07-02 23:29 ` Re: Does TOAST really compress the complete row? Adam Brusselback <adambrusselback@gmail.com>
0 siblings, 1 reply; 5+ messages in thread
From: Tom Lane @ 2020-07-02 22:15 UTC (permalink / raw)
To: Thomas Kellerer <shammat@gmx.net>; +Cc: pgsql-general
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
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: Does TOAST really compress the complete row?
2020-07-02 22:00 Does TOAST really compress the complete row? Thomas Kellerer <shammat@gmx.net>
2020-07-02 22:15 ` Re: Does TOAST really compress the complete row? Tom Lane <tgl@sss.pgh.pa.us>
@ 2020-07-02 23:29 ` Adam Brusselback <adambrusselback@gmail.com>
2020-07-02 23:32 ` Re: Does TOAST really compress the complete row? Adrian Klaver <adrian.klaver@aklaver.com>
0 siblings, 1 reply; 5+ messages in thread
From: Adam Brusselback @ 2020-07-02 23:29 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Thomas Kellerer <shammat@gmx.net>; pgsql-general
Another thing that was said I wasn't aware of and have not been able to
find any evidence to support:
> 10. Blobs don’t participate in Logical replication.
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: Does TOAST really compress the complete row?
2020-07-02 22:00 Does TOAST really compress the complete row? Thomas Kellerer <shammat@gmx.net>
2020-07-02 22:15 ` Re: Does TOAST really compress the complete row? Tom Lane <tgl@sss.pgh.pa.us>
2020-07-02 23:29 ` Re: Does TOAST really compress the complete row? Adam Brusselback <adambrusselback@gmail.com>
@ 2020-07-02 23:32 ` Adrian Klaver <adrian.klaver@aklaver.com>
2020-07-03 00:02 ` Re: Does TOAST really compress the complete row? Adam Brusselback <adambrusselback@gmail.com>
0 siblings, 1 reply; 5+ messages in thread
From: Adrian Klaver @ 2020-07-02 23:32 UTC (permalink / raw)
To: Adam Brusselback <adambrusselback@gmail.com>; Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Thomas Kellerer <shammat@gmx.net>; pgsql-general
On 7/2/20 4:29 PM, Adam Brusselback wrote:
> Another thing that was said I wasn't aware of and have not been able to
> find any evidence to support:
https://www.postgresql.org/docs/12/logical-replication-restrictions.html
"Large objects (see Chapter 34) are not replicated. There is no
workaround for that, other than storing data in normal tables."
Of course that does not apply to bytea:
https://www.postgresql.org/docs/12/datatype-binary.html
>
> > 10. Blobs don’t participate in Logical replication.
--
Adrian Klaver
adrian.klaver@aklaver.com
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: Does TOAST really compress the complete row?
2020-07-02 22:00 Does TOAST really compress the complete row? Thomas Kellerer <shammat@gmx.net>
2020-07-02 22:15 ` Re: Does TOAST really compress the complete row? Tom Lane <tgl@sss.pgh.pa.us>
2020-07-02 23:29 ` Re: Does TOAST really compress the complete row? Adam Brusselback <adambrusselback@gmail.com>
2020-07-02 23:32 ` Re: Does TOAST really compress the complete row? Adrian Klaver <adrian.klaver@aklaver.com>
@ 2020-07-03 00:02 ` Adam Brusselback <adambrusselback@gmail.com>
0 siblings, 0 replies; 5+ messages in thread
From: Adam Brusselback @ 2020-07-03 00:02 UTC (permalink / raw)
To: Adrian Klaver <adrian.klaver@aklaver.com>; +Cc: Tom Lane <tgl@sss.pgh.pa.us>; Thomas Kellerer <shammat@gmx.net>; pgsql-general
>
> > https://www.postgresql.org/docs/12/logical-replication-restrictions.html
> >
> > "Large objects (see Chapter 34) are not replicated. There is no
> > workaround for that, other than storing data in normal tables."
> >
> > Of course that does not apply to bytea:
> >
> https://www.postgresql.org/docs/12/datatype-binary.html
That makes sense now, I was reading that section as if it were talking
about bytea, not LO.
Thanks for pointing that out!
- Adam
^ permalink raw reply [nested|flat] 5+ messages in thread
end of thread, other threads:[~2020-07-03 00:02 UTC | newest]
Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2020-07-02 22:00 Does TOAST really compress the complete row? Thomas Kellerer <shammat@gmx.net>
2020-07-02 22:15 ` Tom Lane <tgl@sss.pgh.pa.us>
2020-07-02 23:29 ` Adam Brusselback <adambrusselback@gmail.com>
2020-07-02 23:32 ` Adrian Klaver <adrian.klaver@aklaver.com>
2020-07-03 00:02 ` Adam Brusselback <adambrusselback@gmail.com>
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