Received: from magus.postgresql.org ([87.238.57.229]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TZkvT-00056D-Ms for pgsql-hackers@postgresql.org; Sat, 17 Nov 2012 16:07:23 +0000 Received: from moutng.kundenserver.de ([212.227.17.10]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TZkvR-0000qu-Vl for pgsql-hackers@postgresql.org; Sat, 17 Nov 2012 16:07:23 +0000 Received: from anarazel.de (p5DDC7A81.dip.t-dialin.net [93.220.122.129]) by mrelayeu.kundenserver.de (node=mreu0) with ESMTP (Nemesis) id 0LwmRY-1TFqW7404W-016JMv; Sat, 17 Nov 2012 17:07:20 +0100 Received: by anarazel.de (Postfix, from userid 1000) id A3C9E1C00E5; Sat, 17 Nov 2012 17:07:18 +0100 (CET) Date: Sat, 17 Nov 2012 17:07:18 +0100 From: Andres Freund To: Noah Misch Cc: Alvaro Herrera , pgsql-hackers@postgresql.org Subject: Re: foreign key locks Message-ID: <20121117160718.GA5675@awork2.anarazel.de> References: <1346389151-sup-8379@alvh.no-ip.org> <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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20121117142020.GB4222@awork2.anarazel.de> X-Provags-ID: V02:K0:8Jf+/Vlqw8Tc+YYFx6ThsDk1wa3tlm/2xHYDKWmttMB 7hg50t+baXkd76O82Ez3jXyXm3ayd0SvXU4jpMQGOwuj/DQS6i O+zR927p6Z49Fjbh/TNpg61FDkUGGoJQJ6m9WedstfUpL8NIpU FkKOthh+W4osWIEfI8ehHucLFQi0YS7dTGfRTGGlxl+LCitMUI aaTtSv1+K1QyB0szV1e9mr9H0ulSLyy20oySwLOsClMCtlxPnn CHBaroIYdjGDdNefibZeBXkTc3dZfvC/IqMNV0+Y2F2gx4hNaK GOjGxpR88vR6O5xmiZVS7gQlrDo8GioIAqiVyuGkgsnK/ESmhq Anp9oWB8inqn7KlO0f7IzxpA27f9h+bzVohM/E7ws X-Pg-Spam-Score: -1.9 (-) X-Archive-Number: 201211/949 X-Sequence-Number: 216801 > > 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... Greetings, Andres Freund -- Andres Freund http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Training & Services