Received: from makus.postgresql.org ([98.129.198.125]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TZn4s-0001Uj-Fg for pgsql-hackers@postgresql.org; Sat, 17 Nov 2012 18:25:14 +0000 Received: from mail-vb0-f46.google.com ([209.85.212.46]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TZn4q-0006VW-NJ for pgsql-hackers@postgresql.org; Sat, 17 Nov 2012 18:25:13 +0000 Received: by mail-vb0-f46.google.com with SMTP id ff1so3914177vbb.19 for ; Sat, 17 Nov 2012 10:25:11 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent :x-gm-message-state; bh=WhMbMWWjG2xM8JmeqrxHDtyG2M0SB1cnoMSKkcWQ/K8=; b=FcEWaflg0VAHi+Do91Me7z9wD4XnIe+Rujxi4SPBHr8HFGROMvqdS6z4CR8gDpKeud h/zAqVRNVq6iwOg/brJfs5U71mycj2cMD7d20b9DSX428LVESr1xE2oNCBKq2fEJV5Ai lcTw2VyGSe6KrOzZOVaxaIXJGcnDAtMhlI8xhzvQf+fWDBrZvJR3k9CMiqehazjjVuh+ sad/7Ea+vmWZZrfBu9VB/zYLH2V66p/XDVw1pfi8XBeziwrba9ypHVCXt05nVcKv8LYJ UvxIAgmAe0Odefhyh5jS99mn97i4pPLADYgRqgrl5A4E8zgAtL+I/S33O+QZ0f4vAFB9 dYag== Received: by 10.58.23.169 with SMTP id n9mr10194060vef.58.1353176711298; Sat, 17 Nov 2012 10:25:11 -0800 (PST) Received: from tornado.leadboat.com (ip68-105-236-221.hr.hr.cox.net. [68.105.236.221]) by mx.google.com with ESMTPS id y7sm2910265vdt.1.2012.11.17.10.25.09 (version=SSLv3 cipher=OTHER); Sat, 17 Nov 2012 10:25:10 -0800 (PST) Date: Sat, 17 Nov 2012 13:25:07 -0500 From: Noah Misch To: Andres Freund Cc: Alvaro Herrera , pgsql-hackers@postgresql.org Subject: Re: foreign key locks Message-ID: <20121117182507.GB32086@tornado.leadboat.com> References: <20121018195820.GO3763@alvh.no-ip.org> <201210270006.54728.andres@2ndquadrant.com> <20121114152347.GA5161@alvh.no-ip.org> <20121114162726.GE5161@alvh.no-ip.org> <20121116002459.GB4347@tornado.leadboat.com> <20121116161747.GC4454@alvh.no-ip.org> <20121116163112.GF6505@awork2.anarazel.de> <20121117033151.GB24972@tornado.leadboat.com> <20121117142020.GB4222@awork2.anarazel.de> <20121117160718.GA5675@awork2.anarazel.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20121117160718.GA5675@awork2.anarazel.de> User-Agent: Mutt/1.5.18 (2008-05-17) X-Gm-Message-State: ALoCoQl+DNoqYEBCdi65QJCquD79hk38GPvj5A0MKTkTIUwUjeJvnFhdkiQvFzt3OwVQWfbBllPW X-Pg-Spam-Score: -2.6 (--) X-Archive-Number: 201211/954 X-Sequence-Number: 216806 On Sat, Nov 17, 2012 at 05:07:18PM +0100, Andres Freund wrote: > > > I agree that tripling FOR SHARE cost is risky. Where is the added cost > > > concentrated? Perchance that multiple belies optimization opportunities. > > > > Good question, let me play a bit. > > Ok, I benchmarked around and from what I see there is no single easy > target. > The biggest culprits I could find are: > 1. higher amount of XLogInsert calls per transaction (visible > in pgbench -t instead of -T mode while watching the WAL volume) > 2. Memory allocations in GetMultiXactIdMembers > 3. Memory allocations in mXactCachePut > a) cache entry itself > b) the cache context > 4. More lwlocks acquisitions > > We can possibly optimize a bit with 2) by using a static buffer for > common member sizes, but thats not going to buy us too much... In that case, +1 for your proposal to prop up FOR SHARE.