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 1riCED-00Fepp-Kp for pgsql-hackers@arkaria.postgresql.org; Thu, 07 Mar 2024 11:48:02 +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 1riCEB-0054EX-St for pgsql-hackers@arkaria.postgresql.org; Thu, 07 Mar 2024 11:48:00 +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 1riCB6-004zdU-2t for pgsql-hackers@lists.postgresql.org; Thu, 07 Mar 2024 11:44:48 +0000 Received: from mail-wr1-x42b.google.com ([2a00:1450:4864:20::42b]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1riCB1-003FwJ-TG for pgsql-hackers@lists.postgresql.org; Thu, 07 Mar 2024 11:44:47 +0000 Received: by mail-wr1-x42b.google.com with SMTP id ffacd0b85a97d-33e383546c1so403575f8f.2 for ; Thu, 07 Mar 2024 03:44:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=enterprisedb.com; s=google; t=1709811882; x=1710416682; darn=lists.postgresql.org; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=T9YK9EM3m2M+mwrZ+dtmEoN/ETUles/H8YRkPXg9aKo=; b=MFCXYAIq2JSyrL98LSiJw+MYEc9JPvv8tt1Hm+v9iUOyQK1rY13nCoh4vHjjY6IVYx +h3gTD5fB9338UbomHbmyEhMXEDKiHenUPs8QeLw2efOKaWcdWboq1YcfcdAk0ntEquP Zi5j/dPTXvjzHPhLdrvmRljq3YOXZ8KeWwB/SiucRaGI0Vx7wybhb1d1BvloVifVzpP+ i6+Q4ao1lQwg7lWmdfo2IeXAr4W4aTPhrKFPH7VggmOnPeH7hfKwL5NSc9rKT/+R/SPi RjaQub+TkM1jC3iLAsnDihjfHE8ctyhr8r9WKDDqBLKEBufKauQfm4uaQ/qTaqCcD/Il N3xg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709811882; x=1710416682; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=T9YK9EM3m2M+mwrZ+dtmEoN/ETUles/H8YRkPXg9aKo=; b=S0X4MfdC7UnbgfOxvyGtQx01w+y8seZA1qKc080NQjHKYBvXGPm1p+x448J3LFYrD/ OGr4xOxlTJGn122D0S7x355XNsLWHIHyq1Ngt9/t657P+TOwuhYXo639XjUl7WSzmMeV J7Qs3/6UW4AXDq08RQoBrWKKeoTDGBnzAaiEtPlJCBB7w9BRJfMr+6oa5Tupsix37n8K hPkPZ7TWfKil8T5kEGz1IbjTSEMW0lAX1zSOQOkjKQvlPHHgDDZ9fhpTzmYgqBxe+2St NyzGKPVzkkgFpnfTtwuHqaDNTI+4GfDwpux//FZetqKl5RMGsdlawe30VbWisYsFqsij FsAw== X-Forwarded-Encrypted: i=1; AJvYcCWyiSW+ycAYtUPWQRKHP/OQ4X8sQ5bbZin/Rd4l6HBF/JFVEecbxFIvlJmJhbsBTIWJpt6LQ4nTWyM18i3OrH7uZag7dk8uxjVTxbD9TqnhDArK X-Gm-Message-State: AOJu0Yw52+QtsfPIDJhtszWWTgbX7c7iqe0YVSPIv4ATa8gPSRFtKRZZ ykW0hGqVprktSxYnEhF1Av4ox1G8K4ii5AAkiccQ/asocGZDhymowtG3hOsvAA== X-Google-Smtp-Source: AGHT+IEeLagOTC1CO0lh3w+HXCZo05nFKdMUhFhYs+ITZMNtDiQwL6IK6X/i/4vhSeXUMPVOKKOL4w== X-Received: by 2002:adf:e9d1:0:b0:33d:c6dd:b4b2 with SMTP id l17-20020adfe9d1000000b0033dc6ddb4b2mr11795386wrn.54.1709811882189; Thu, 07 Mar 2024 03:44:42 -0800 (PST) Received: from [10.137.0.18] (ip-86-49-229-30.bb.vodafone.cz. [86.49.229.30]) by smtp.gmail.com with ESMTPSA id cr11-20020a05600004eb00b0033dd2c3131fsm19836350wrb.65.2024.03.07.03.44.41 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 07 Mar 2024 03:44:41 -0800 (PST) Message-ID: Date: Thu, 7 Mar 2024 12:44:41 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Shared detoast Datum proposal Content-Language: en-US To: Nikita Malakhov Cc: Andy Fan , Michael Zhilin , Peter Smith , vignesh C , Matthias van de Meent , pgsql-hackers@lists.postgresql.org References: <87il4jrk1l.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> <875xyb1a6q.fsf@163.com> <87zfvedbsr.fsf@163.com> <87y1axc1o1.fsf@163.com> <05aca065-f1f1-48af-b0e8-5eaa72ee6b6f@enterprisedb.com> <87ttllbd00.fsf@163.com> <233cce7b-d9ae-4605-9b76-1f3b98cbc7f0@enterprisedb.com> From: Tomas Vondra In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 3/7/24 08:33, Nikita Malakhov wrote: > Hi! > > Tomas, I thought about this issue - >> What if you only need the first slice? In that case decoding everything >> will be a clear regression. > And completely agree with you, I'm currently working on it and will post > a patch a bit later. Cool. I don't plan to work on improving my patch - it was merely a PoC, so if you're interested in working on that, that's good. > Another issue we have here - if we have multiple slices requested - > then we have to update cached slice from both sides, the beginning > and the end. > No opinion. I haven't thought about how to handle slices too much. > On update, yep, you're right >> Surely the update creates a new TOAST value, with a completely new TOAST >> pointer, new rows in the TOAST table etc. It's not updated in-place. So >> it'd end up with two independent entries in the TOAST cache. > >> Or are you interested just in evicting the old value simply to free the >> memory, because we're not going to need that (now invisible) value? That >> seems interesting, but if it's too invasive or complex I'd just leave it >> up to the LRU eviction (at least for v1). > Again, yes, we do not need the old value after it was updated and > it is better to take care of it explicitly. It's a simple and not invasive > addition to your patch. > OK > Could not agree with you about large values - it makes sense > to cache large values because the larger it is the more benefit > we will have from not detoasting it again and again. One way > is to keep them compressed, but what if we have data with very > low compression rate? > I'm not against caching large values, but I also think it's not difficult to construct cases where it's a losing strategy. > I also changed HASHACTION field value from HASH_ENTER to > HASH_ENTER_NULL to softly deal with case when we do not > have enough memory and added checks for if the value was stored > or not. > I'm not sure about this. HASH_ENTER_NULL is only being used in three very specific places (two are lock management, one is shmeminitstruct). This hash table is not unique in any way, so why not to use HASH_ENTER like 99% other hash tables? regards -- Tomas Vondra EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company