X-Original-To: pgsql-hackers-postgresql.org@postgresql.org Received: from localhost (wm.hub.org [200.46.204.128]) by postgresql.org (Postfix) with ESMTP id E23EF9FC27A for ; Sat, 26 Aug 2006 17:08:08 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.128]) (amavisd-new, port 10024) with ESMTP id 17667-03 for ; Sat, 26 Aug 2006 20:08:05 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey- Received: from joeconway.com (joeconway.com [68.15.9.201]) by postgresql.org (Postfix) with ESMTP id 410B89FC279 for ; Sat, 26 Aug 2006 17:08:05 -0300 (ADT) Received: from [192.168.4.40] (account jconway [192.168.4.40] verified) by joeconway.com (CommuniGate Pro SMTP 4.1.8) with ESMTP-TLS id 4206444; Sat, 26 Aug 2006 13:08:03 -0700 Message-ID: <44F0AA23.9030800@joeconway.com> Date: Sat, 26 Aug 2006 13:08:03 -0700 From: Joe Conway User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.7.13) Gecko/20060501 Fedora/1.7.13-1.1.fc5 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Bruce Momjian CC: Tom Lane , "Hackers (PostgreSQL)" Subject: Re: VALUES clause memory optimization References: <200608260335.k7Q3ZeJ04955@momjian.us> In-Reply-To: <200608260335.k7Q3ZeJ04955@momjian.us> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200608/1750 X-Sequence-Number: 89243 Bruce Momjian wrote: > Has this been addressed? > >>Tom Lane wrote: >>>The reason we could safely list_free inside transformInsertRow is that >>>we know all its callers have just built the passed-in list and so there >>>are no other pointers to it. That doesn't apply in the general case of >>>grammar output. After another look, even in this case there could be other pointers. Starting around line 667 of analyze.c: 8<------------------ foreach(lc, selectQuery->targetList) { TargetEntry *tle = (TargetEntry *) lfirst(lc); Expr *expr; if (tle->resjunk) continue; if (tle->expr && (IsA(tle->expr, Const) ||IsA(tle->expr, Param)) && exprType((Node *) tle->expr) == UNKNOWNOID) expr = tle->expr; else expr = (Expr *) makeVar(rtr->rtindex, tle->resno, exprType((Node *) tle->expr), exprTypmod((Node *) tle->expr), 0); exprList = lappend(exprList, expr); } /* Prepare row for assignment to target table */ exprList = transformInsertRow(pstate, exprList, stmt->cols, icolumns, attrnos); 8<------------------ So in the UNKNOWNOID case, it wouldn't be safe to free the node after transformation because it originates in the grammar output. The *only* safe thing to free up would be a the input exprList itself. Not much to be saved there. >>>My advice is to get that low-hanging fruit >>>in transformInsertRow and leave the other ideas for 8.3. This one case doesn't provide that much memory savings by itself anyway. I guess we'll just live with it until we can come up with a safe way to free grammar output. Joe