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 1rgsT0-008Qry-L6 for pgsql-hackers@arkaria.postgresql.org; Sun, 03 Mar 2024 20:29:51 +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 1rgsSz-002EDC-2o for pgsql-hackers@arkaria.postgresql.org; Sun, 03 Mar 2024 20:29:49 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rgsSy-002ED4-Rb for pgsql-hackers@lists.postgresql.org; Sun, 03 Mar 2024 20:29:49 +0000 Received: from mail-wr1-x42f.google.com ([2a00:1450:4864:20::42f]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1rgsSu-002gfC-Nj for pgsql-hackers@lists.postgresql.org; Sun, 03 Mar 2024 20:29:47 +0000 Received: by mail-wr1-x42f.google.com with SMTP id ffacd0b85a97d-33e17fc5aceso1591102f8f.0 for ; Sun, 03 Mar 2024 12:29:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=enterprisedb.com; s=google; t=1709497784; x=1710102584; 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=tKWEtYzQfqbQeilFPTWSuvA/gWXbobtUWGwM8vQtKCM=; b=Hop829hfpOaGvs6O9KS0TO47V+DF5GBPyrDqBshHajSQgP7DNktbIzB7CrpIz7fseY +SmdJ6SEww2gzO5pRAoS2H+u/hurbSfaiZtvxylrq4OOfc8uX8vCrQjH1bgobojvC6Q4 uL2XDLcbz7DhWXO/agiROS3+gZiS7I3nHkPWHZ4mJjolT2oeJwp8yIht/D27e4uJ7GP/ VQ4lZ2R9ppkG3QySIe9Exwz1JY2Ueq2ACDGVkZ2KbS58/5laFQQmYfYw7sxEkw4TH2ns Txu70PSHv9IvUCKvYnlUM1MCX275ec0c9H+vXn9m3FcDmmxyMgkbarJOj4n565jWo88O uWfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709497784; x=1710102584; 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=tKWEtYzQfqbQeilFPTWSuvA/gWXbobtUWGwM8vQtKCM=; b=VqGvmUsrCdnpSGWFCznSXTs1GIUIjUv+w86GnC965EAX7k8tZu7bewNDZl95W59zkJ NJ75FumIQmn/PBradr+EoAECWRED1JNd5iRkZxkvwf0zLIENjQW0VPDXz9krfoVAmie2 ittBOLFbSqJIvICik0bUPE8D8IJCyZU/5Avh7WwF4puHCB0RB+rXrwuTKtrfPuMeseey IihEyhEXysIbZ/a1EK4Dg1eW6eVXNDZJdbCCDnj16W4WbCVPjIEDMVDKwKNYd7QozJti 6Mc0ptGITEePumPqI7Y+2iyxYs7oQZ03+aYdN3shVR65k2E9mDunuQorD5a/ruQyRkxf zeAQ== X-Forwarded-Encrypted: i=1; AJvYcCW5cYQ3sxZ7i+Ix/+AvugNErdxel8NLWaA+Q3yanRLILqfE9VhnH5tXk3QsaTsGfAra4n0t0Im1N/wyGBENaWJuSHOY3Nx4TeGhDJcJtBsIoeoG X-Gm-Message-State: AOJu0Yxvrz0yA1tSx78fG+TFq4OvtvW1XobywZ6tCwCH29pmWv2leyRx y7ZuJPKB7bYnXRmskTAz37JUgm5E/kSeSUOtDT/qTHE5z1k9CgHmqgKjQ2mE/NK0zdn37ty+ovI = X-Google-Smtp-Source: AGHT+IFfP2au2stGeepWXb8Jk70iFRcW4HAvJpskL83Te1jSsk5xsVo3m4+tdsWT964iosgwTcUnDg== X-Received: by 2002:adf:fdd0:0:b0:33d:aae7:7d07 with SMTP id i16-20020adffdd0000000b0033daae77d07mr6611286wrs.18.1709497784339; Sun, 03 Mar 2024 12:29:44 -0800 (PST) Received: from [10.137.0.18] (ip-86-49-225-243.bb.vodafone.cz. [86.49.225.243]) by smtp.gmail.com with ESMTPSA id d15-20020a5d644f000000b0033e052be14fsm10296653wrw.98.2024.03.03.12.29.43 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 03 Mar 2024 12:29:43 -0800 (PST) Message-ID: Date: Sun, 3 Mar 2024 21:29:42 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Shared detoast Datum proposal Content-Language: en-US To: Andy Fan Cc: Nikita Malakhov , Michael Zhilin , Peter Smith , vignesh C , Matthias van de Meent , pgsql-hackers@lists.postgresql.org References: <87il4jrk1l.fsf@163.com> <87h6jxw41k.fsf@163.com> <87sf3andy2.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> <875xyb1a6q.fsf@163.com> From: Tomas Vondra In-Reply-To: <875xyb1a6q.fsf@163.com> 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 2/26/24 16:29, Andy Fan wrote: > > ...> > I can understand the benefits of the TOAST cache, but the following > issues looks not good to me IIUC: > > 1). we can't put the result to tts_values[*] since without the planner > decision, we don't know if this will break small_tlist logic. But if we > put it into the cache only, which means a cache-lookup as a overhead is > unavoidable. True - if you're comparing having the detoasted value in tts_values[*] directly with having to do a lookup in a cache, then yes, there's a bit of an overhead. But I think from the discussion it's clear having to detoast the value into tts_values[*] has some weaknesses too, in particular: - It requires decisions which attributes to detoast eagerly, which is quite invasive (having to walk the plan, ...). - I'm sure there will be cases where we choose to not detoast, but it would be beneficial to detoast. - Detoasting just the initial slices does not seem compatible with this. IMHO the overhead of the cache lookup would be negligible compared to the repeated detoasting of the value (which is the current baseline). I somewhat doubt the difference compared to tts_values[*] will be even measurable. > > 2). It is hard to decide which entry should be evicted without attaching > it to the TupleTableSlot's life-cycle. then we can't grantee the entry > we keep is the entry we will reuse soon? > True. But is that really a problem? I imagined we'd set some sort of memory limit on the cache (work_mem?), and evict oldest entries. So the entries would eventually get evicted, and the memory limit would ensure we don't consume arbitrary amounts of memory. We could also add some "slot callback" but that seems unnecessary. regards -- Tomas Vondra EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company