Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 42CD9B5DBC8 for ; Fri, 1 Jul 2011 18:59:48 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 15882-09 for ; Fri, 1 Jul 2011 21:59:42 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by mail.postgresql.org (Postfix) with ESMTP id 1BAD7B5D803 for ; Fri, 1 Jul 2011 18:59:41 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id p61LxbVT006039; Fri, 1 Jul 2011 17:59:37 -0400 (EDT) To: Alvaro Herrera cc: Matthijs Bomhoff , pgsql-bugs Subject: Re: Bug with plpgsql, temp tables and TOAST? In-reply-to: <1309363131-sup-6268@alvh.no-ip.org> References: <0C41674C-FA02-4768-9E1B-548E568875BD@quarantainenet.nl> <1309363131-sup-6268@alvh.no-ip.org> Comments: In-reply-to Alvaro Herrera message dated "Wed, 29 Jun 2011 12:03:20 -0400" Date: Fri, 01 Jul 2011 17:59:37 -0400 Message-ID: <6038.1309557577@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.91 tagged_above=-5 required=5 tests=BAYES_00=-1.9, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201107/4 X-Sequence-Number: 30616 Alvaro Herrera writes: > Hmm, so what's happening here, I think, is that the value is getting > assigned to the record variable without detoasting. I guess we should > detoast the value prior to assigning it, but it seems to me that that > would have a large performance penalty for other cases in which the > toast table is not dropped; in fact, you can even imagine some cases in > which the toasted value is not even accessed, so getting to the point of > detoasting it would be a severe penalization. Yeah, we have seen similar reports before, and concluded that forcibly detoasting on the remote chance that the toast table wouldn't stick around was just untenable from a performance standpoint. It's annoying but I don't see a good compromise solution ATM. Pavel was working recently on a hack to prevent repeated detoastings, which is at least somewhat related to this issue. I don't recall that anyone liked his hack though ... regards, tom lane