Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rgxFo-008ou8-Fj for pgsql-hackers@arkaria.postgresql.org; Mon, 04 Mar 2024 01:36:32 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1rgxFm-003A8Q-ND for pgsql-hackers@arkaria.postgresql.org; Mon, 04 Mar 2024 01:36:31 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rgxFm-003A8I-Du for pgsql-hackers@lists.postgresql.org; Mon, 04 Mar 2024 01:36:30 +0000 Received: from m15.mail.163.com ([45.254.50.219]) by magus.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1rgxFh-002ddF-RW for pgsql-hackers@lists.postgresql.org; Mon, 04 Mar 2024 01:36:29 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-ID:MIME-Version: Content-Type; bh=Wr5FiYCtLBpEN9jmHzZjEP+eDsMlZ9VoUMhbO1crGfM=; b=OkIlY9nncIa1YrI8YCj+IVr3fxuYbUn/1e4oAJFmeDMLlJZxAyWVLckcdubzBu jidwoVUxdObQIDwqq7LOlRb/k3kbLbpAAh6c6f2W5E17jzBCwPATOT2HpvLTiYfg kNa+5x+BeVtsOznssVHtfy374cZ4JXz+Dr0/NAGdD5iQg= Received: from 8235eee8a2a0 (unknown [140.205.118.118]) by gzga-smtp-mta-g0-1 (Coremail) with SMTP id _____wDnF_qOJeVl1hTjAA--.12679S3; Mon, 04 Mar 2024 09:36:15 +0800 (CST) References: <87il4jrk1l.fsf@163.com> <87wmskm9qu.fsf@163.com> <87v87kvboq.fsf@163.com> <71321d83-391b-473b-aaf6-618c7f682b96@postgrespro.ru> <87r0i7vos3.fsf@163.com> <874je3hcwn.fsf@163.com> <8734tmg88e.fsf@163.com> <7f4c8673-4c5d-4dbf-b8e5-0ec11cd2fba0@enterprisedb.com> <87h6i2djf9.fsf@163.com> <87jzms0xza.fsf@163.com> <87frxf1gld.fsf@163.com> <871q8z19ux.fsf@163.com> <87msrgdq93.fsf@163.com> <87frx7et1j.fsf@163.com> User-agent: mu4e 1.10.7; emacs 29.1 From: Andy Fan To: Tomas Vondra Cc: Nikita Malakhov , Michael Zhilin , Peter Smith , vignesh C , Matthias van de Meent , pgsql-hackers@lists.postgresql.org Subject: Re: Shared detoast Datum proposal Date: Mon, 04 Mar 2024 09:29:53 +0800 In-reply-to: Message-ID: <87v862dbht.fsf@163.com> MIME-Version: 1.0 Content-Type: text/plain X-CM-TRANSID: _____wDnF_qOJeVl1hTjAA--.12679S3 X-Coremail-Antispam: 1Uf129KBjvJXoW7trWfXFykKrWktFyxuryxAFb_yoW8Ar4Upr W3GFy2vr4DArn5t3Wvg3Wkta4fJw4rGrW3GFn3tr9a9FWfZryIyryjgF40kayDGrW8Za4a qF4YgayDXrW8Aa7anT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x0zRpwZ3UUUUU= X-Originating-IP: [140.205.118.118] X-CM-SenderInfo: x2klx3xlid0iqsrtqiywtou0bp/xtbBzxGXU2V4IDdSJwAAsl List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Tomas Vondra writes: > On 3/3/24 07:10, Andy Fan wrote: >> >> Hi, >> >> Here is a updated version, the main changes are: >> >> 1. an shared_detoast_datum.org file which shows the latest desgin and >> pending items during discussion. >> 2. I removed the slot->pre_detoast_attrs totally. >> 3. handle some pg_detoast_datum_slice use case. >> 4. Some implementation improvement. >> > > I only very briefly skimmed the patch, and I guess most of my earlier > comments still apply. Yes, the overall design is not changed. > But I'm a bit surprised the patch needs to pass a > MemoryContext to so many places as a function argument - that seems to > go against how we work with memory contexts. Doubly so because it seems > to only ever pass CurrentMemoryContext anyway. So what's that about? I think you are talking about the argument like this: /* ---------- - * detoast_attr - + * detoast_attr_ext - * * Public entry point to get back a toasted value from compression * or external storage. The result is always non-extended varlena form. * + * ctx: The memory context which the final value belongs to. + * * Note some callers assume that if the input is an EXTERNAL or COMPRESSED * datum, the result will be a pfree'able chunk. * ---------- */ +extern struct varlena * +detoast_attr_ext(struct varlena *attr, MemoryContext ctx) This is mainly because 'detoast_attr' will apply more memory than the "final detoast datum" , for example the code to scan toast relation needs some memory as well, and what I want is just keeping the memory for the final detoast datum so that other memory can be released sooner, so I added the function argument for that. -- Best Regards Andy Fan