pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tomas Vondra <tomas.vondra@enterprisedb.com>
To: Andy Fan <zhihuifan1213@163.com>
To: Nikita Malakhov <hukutoc@gmail.com>
Cc: Michael Zhilin <m.zhilin@postgrespro.ru>
Cc: Peter Smith <smithpb2250@gmail.com>
Cc: vignesh C <vignesh21@gmail.com>
Cc: Matthias van de Meent <boekewurm+postgres@gmail.com>
Cc: pgsql-hackers@lists.postgresql.org
Subject: Re: Shared detoast Datum proposal
Date: Mon, 26 Feb 2024 15:13:06 +0100
Message-ID: <fea81484-09b5-499d-80d0-acb8df43d047@enterprisedb.com> (raw)
In-Reply-To: <87frxf1gld.fsf@163.com>
References: <87il4jrk1l.fsf@163.com>
	<87h6jxw41k.fsf@163.com>
	<CALDaNm2EtgXGd+w81ZjTZBD_rLSURyGqXRoz7EFfhxEneOmWig@mail.gmail.com>
	<87sf3andy2.fsf@163.com>
	<87wmskm9qu.fsf@163.com>
	<CAHut+PsehMtwQ4uE9VS2C7jB1yT0SZVOPU22u1=ma1K7dKFUow@mail.gmail.com>
	<87v87kvboq.fsf@163.com>
	<71321d83-391b-473b-aaf6-618c7f682b96@postgrespro.ru>
	<87r0i7vos3.fsf@163.com>
	<874je3hcwn.fsf@163.com>
	<c066e988-38b9-460f-9e9d-aedd2482bff2@enterprisedb.com>
	<8734tmg88e.fsf@163.com>
	<7f4c8673-4c5d-4dbf-b8e5-0ec11cd2fba0@enterprisedb.com>
	<87h6i2djf9.fsf@163.com>
	<87jzms0xza.fsf@163.com>
	<CAN-LCVMU_AzYNDQ-MgX3xc5qCnhTgO1LWKUCygOu3neBM-y94g@mail.gmail.com>
	<87frxf1gld.fsf@163.com>


On 2/26/24 14:22, Andy Fan wrote:
> 
>...
>
>> Also, toasted values
>> are not always being used immediately and as a whole, i.e. jsonb values are fully
>> detoasted (we're working on this right now) to extract the smallest value from
>> big json, and these values are not worth keeping in memory. For text values too,
>> we often do not need the whole value to be detoasted.
> 
> I'm not sure how often this is true, espeically you metioned text data
> type. I can't image why people acquire a piece of text and how can we
> design a toasting system to fulfill such case without detoast the whole
> as the first step. But for the jsonb or array data type, I think it is
> more often. However if we design toasting like that, I'm not sure if it
> would slow down other user case. for example detoasting the whole piece
> use case. I am justing feeling both way has its user case, kind of heap
> store and columna store.  
> 

Any substr/starts_with call benefits from this optimization, and such
calls don't seem that uncommon. I certainly can imagine people doing
this fairly often. In any case, it's a long-standing behavior /
optimization, and I don't think we can just dismiss it this quickly.

Is there a way to identify cases that are likely to benefit from this
slicing, and disable the detoasting for them? We already disable it for
other cases, so maybe we can do this here too?

Or maybe there's a way to do the detoasting lazily, and only keep the
detoasted value when it's requesting the whole value. Or perhaps even
better, remember what part we detoasted, and maybe it'll be enough for
future requests?

I'm not sure how difficult would this be with the proposed approach,
which eagerly detoasts the value into tts_values. I think it'd be easier
to implement with the TOAST cache I briefly described ...


regards

-- 
Tomas Vondra
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company





view thread (53+ messages)  latest in thread

Message-ID: <fea81484-09b5-499d-80d0-acb8df43d047@enterprisedb.com>
Permalink:  ../fea81484-09b5-499d-80d0-acb8df43d047@enterprisedb.com/
Also on:    postgresql.org/message-id/fea81484-09b5-499d-80d0-acb8df43d047@enterprisedb.com

 · 

reply

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-hackers@postgresql.org
  Cc: tomas.vondra@enterprisedb.com, zhihuifan1213@163.com, hukutoc@gmail.com, m.zhilin@postgrespro.ru, smithpb2250@gmail.com, vignesh21@gmail.com, boekewurm+postgres@gmail.com
  Subject: Re: Shared detoast Datum proposal
  In-Reply-To: <fea81484-09b5-499d-80d0-acb8df43d047@enterprisedb.com>
  References: <87il4jrk1l.fsf@163.com> <87h6jxw41k.fsf@163.com> <CALDaNm2EtgXGd+w81ZjTZBD_rLSURyGqXRoz7EFfhxEneOmWig@mail.gmail.com> <87sf3andy2.fsf@163.com> <87wmskm9qu.fsf@163.com> <CAHut+PsehMtwQ4uE9VS2C7jB1yT0SZVOPU22u1=ma1K7dKFUow@mail.gmail.com> <87v87kvboq.fsf@163.com> <71321d83-391b-473b-aaf6-618c7f682b96@postgrespro.ru> <87r0i7vos3.fsf@163.com> <874je3hcwn.fsf@163.com> <c066e988-38b9-460f-9e9d-aedd2482bff2@enterprisedb.com> <8734tmg88e.fsf@163.com> <7f4c8673-4c5d-4dbf-b8e5-0ec11cd2fba0@enterprisedb.com> <87h6i2djf9.fsf@163.com> <87jzms0xza.fsf@163.com> <CAN-LCVMU_AzYNDQ-MgX3xc5qCnhTgO1LWKUCygOu3neBM-y94g@mail.gmail.com> <87frxf1gld.fsf@163.com> <fea81484-09b5-499d-80d0-acb8df43d047@enterprisedb.com>

* 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