Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fNqlj-0000N9-5h for pgsql-general@arkaria.postgresql.org; Wed, 30 May 2018 02:23:19 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fNqlg-0007Kq-I2 for pgsql-general@arkaria.postgresql.org; Wed, 30 May 2018 02:23:16 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fNqlg-0007Kg-A8 for pgsql-general@lists.postgresql.org; Wed, 30 May 2018 02:23:16 +0000 Received: from mail-io0-f177.google.com ([209.85.223.177]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1fNqlX-000268-LN for pgsql-general@postgresql.org; Wed, 30 May 2018 02:23:15 +0000 Received: by mail-io0-f177.google.com with SMTP id d22-v6so5278471iof.13 for ; Tue, 29 May 2018 19:23:06 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:subject:to:cc:references:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=+UkEE2Xgxj2hUkID9PO7RyKR9wZHaOXh5nbGicriXYY=; b=tRmG5LsJPwpvLcwysG4CpAl9If37OOglYRR9GGbZtlzcgiNW8y0GshR6lWNua9JQqX 3wNaFLL/0qG033yOjel/MQXcNj2BGWoOZi6dJDKAwi3QRk1n8TYF2pWxnMSW3NhxIRAe pr1YdMT14f2XReiRpMhdibKj2h8d9HMxrdaNm89LzcR1Vjqr0s40U1x1PGtLqU26Jyvr g8h6/6ordpjt2IkE5X5pJIkJ7Zu41dsmhujXn+u/kJFejOYL5rFfytxmXYrzQSgleXfM iogj36uTScIoo3WiQGjBRrNCbP25f6rx0WIEcL6MKJ70zaxgvgU/107ginmPYOG8ryb0 dXsw== X-Gm-Message-State: ALKqPweCLWDY81Ce+rZg/kKReR1XHhCqNLTKHX6y0/3GH3oi/9iSAIFO h2acA3M7Kl+Hc4sfA52JfIc= X-Google-Smtp-Source: ADUXVKLpqHZiAM8GeqO5XbeuifedEBxvNN7RDYjBUUYGs8VRAmL317Z/1Rb8gZfguRz7JIyeBatVSA== X-Received: by 2002:a6b:ba83:: with SMTP id k125-v6mr657317iof.177.1527646985250; Tue, 29 May 2018 19:23:05 -0700 (PDT) Received: from fuji.home ([65.183.81.59]) by smtp.gmail.com with ESMTPSA id q202-v6sm2170146iod.30.2018.05.29.19.23.03 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 29 May 2018 19:23:04 -0700 (PDT) Received: from fuji.home (fuji.home [10.1.65.222]) by fuji.home (Postfix) with ESMTPS id 1BF0D680076; Tue, 29 May 2018 20:22:55 -0600 (MDT) From: Stuart McGraw Subject: Re: existence of a savepoint? To: pgsql-general Cc: "David G. Johnston" References: <857d29bf-515d-e624-9e0a-135e9e28e91b@mtneva.com> <20180529230106.o46llmha7nsfqoqn@alvherre.pgsql> Message-ID: Date: Tue, 29 May 2018 20:22:55 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 05/29/2018 05:18 PM, David G. Johnston wrote: > On Tue, May 29, 2018 at 4:01 PM, Alvaro Herrera >wrote: > > On 2018-May-29, Stuart McGraw wrote: > > > Alternatively if there were a setting to tell Postgresql to > > follow the SQL standard behavior of overwriting rather stacking > > savepoints, that too would also solve my current problem I think. > > Perhaps it is just my limited experience but the former behavior > > has always seemed more useful in practice than the latter. > > I think if what we're doing breaks the semantics of the SQL spec, we're > definitely open to changing our behavior.  But that wouldn't solve your > problem today.  What I think could solve your problem today is a > C-language extension that uses xact.c callbacks in order to expose a > list that you can query from user space. > > ​Stuart:​ > > That said, have you measured this "leaking" and can show that it is non-trivial (given the large size of the overall transaction)? No I haven't and am not sure how I would. Are you saying I shouldn't worry about it and just not bother releasing any of the savepoints? I would feel a little uneasy about that the same way I would feel about a program that never freed allocated memory or closed open files. If I know there are relatively small limits on how much data will be processed or how long the program will run, sure. But in my case I don't control the size of the input data and I don't understand the internals of savepoints so I think caution is prudent. Also I'm not sure the warnings against premature optimization when talking about code performance tweaks apply to resource leaks. The former attempt to make a program run faster but don't (in theory) affect its correctness. Resource problems often show up unexpectedly and catastrophically. So being more preemptively concerned about the latter I think is justified. > Beyond that bulk ETL leveraging SAVEPOINT is not something I've encountered or contemplated.  Expecting and reacting to errors is expensive and itself error-prone.  I'd much rather try to design something that where failure is simply bad - usually by bulk loading with fewer constraints and then ensuring that future queries don't attempt to do something illegal like insert duplicates. Funny you should say that :-) I am looking at rewriting these import programs (there are several) to do just that. But it is not a trivial job and in the meantime I need to keep what already exists, working.