Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Tdqu4-0003gy-IE for pgsql-performance@arkaria.postgresql.org; Wed, 28 Nov 2012 23:18:52 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1Tdqu3-00033l-TF for pgsql-performance@arkaria.postgresql.org; Wed, 28 Nov 2012 23:18:51 +0000 Received: from magus.postgresql.org ([87.238.57.229]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Tdqu3-00033g-3q for pgsql-performance@postgresql.org; Wed, 28 Nov 2012 23:18:51 +0000 Received: from mail-pa0-f46.google.com ([209.85.220.46]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Tdqtz-0000Nw-H6 for pgsql-performance@postgresql.org; Wed, 28 Nov 2012 23:18:50 +0000 Received: by mail-pa0-f46.google.com with SMTP id bh2so7140800pad.19 for ; Wed, 28 Nov 2012 15:18:46 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=subject:from:to:cc:in-reply-to:references:content-type:date :message-id:mime-version:x-mailer:content-transfer-encoding :x-gm-message-state; bh=0nXOfgS1wvgyUXziLjuPFWiebmuOP0haLZYxtFL17wQ=; b=dEwc/tK5HndbZekrQ+NFg1w07SSF51L/R1x3mIa5n1NHmuw+Z5as+j1EjQdU34nTQY nAWMxFJEZPqEElZPBNA25vWPaI8I8hmg35kUzv/ACEWpsqbKmwG8bUwNZy2v0lVEHLOU MdUDHQLsxNKVIu1gLKDEkGrPVBcboDQ7elk9C4Zjyo4elFDlgYx0+yThs82+e+xe6IOi KWniRfxgNgzTeKsURE66pJ9u0vzpgjlGEVmkAghtIc+IHuFBcuzil1PaiTWe8hoy4cr/ QykNeFux3rK8VgE3Jb6+iRB+UbkkWuqaBhjUXofT4LxumOuFUaPBsowBHPRhPMXdZwHj 7sqA== Received: by 10.66.79.167 with SMTP id k7mr56807866pax.24.1354144725953; Wed, 28 Nov 2012 15:18:45 -0800 (PST) Received: from ?IPv6:::1? ([2600:3c01::f03c:91ff:fe93:2ae4]) by mx.google.com with ESMTPS id c1sm13226532pav.23.2012.11.28.15.18.43 (version=SSLv3 cipher=OTHER); Wed, 28 Nov 2012 15:18:45 -0800 (PST) Subject: Re: Savepoints in transactions for speed? From: Jeff Davis To: Claudio Freire Cc: Mike Blackwell , "pgsql-performance@postgresql.org" In-Reply-To: References: <2000E26E-35FC-4801-90F3-3CFBDA7B41DF@yahoo.com> Content-Type: text/plain; charset="ISO-8859-1" Date: Wed, 28 Nov 2012 15:18:42 -0800 Message-ID: <1354144722.1766.74.camel@sussancws0025> Mime-Version: 1.0 X-Mailer: Evolution 2.28.3 Content-Transfer-Encoding: 7bit X-Gm-Message-State: ALoCoQn2mZqzNtko/3XnVFJg3QnVetNbRHSRPC/Rp2jJ9grIdXk071Lhrhf15ryh7H6Vqn5oiGUk X-Pg-Spam-Score: -2.6 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-performance Precedence: bulk Sender: pgsql-performance-owner@postgresql.org On Tue, 2012-11-27 at 22:16 -0300, Claudio Freire wrote: > Updates, are faster if batched, if your business logic allows it, > because it creates less bloat and creates more opportunities for with > HOT updates. I don't think it applies to inserts, though, and I > haven't heard it either. Huge updates (e.g. UPDATE with no WHERE clause) are less likely to benefit from HOT. HOT has two main optimizations: 1. Remove dead tuples faster without waiting for VACUUM -- this only works if the transaction that updated/deleted the tuple actually finished (otherwise the tuple can't be removed yet), so it only benefits the *next* update to come along. But if it's one big update, then VACUUM is probably just as good at cleaning up the space. 2. Doesn't make new index entries for the new tuple; reuses the old index entries -- this only works if the update is on the same page, but large updates tend to fill pages up (because of the buildup of dead tuples) and force new to go to new pages. HOT is essentially designed for lots of small updates, which didn't perform well before PG 8.3. Batching of inserts/updates/deletes has a big benefit over separate transactions, but only up to a point, after which it levels off. I'm not sure exactly when that point is, but after that, the downsides of keeping a transaction open (like inability to remove the previous version of an updated tuple) take over. Regards, Jeff Davis -- Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance