Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1ZD7gm-0006cv-Jf for pgsql-performance@arkaria.postgresql.org; Thu, 09 Jul 2015 09:00:16 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1ZD7gl-0004Ij-P1 for pgsql-performance@arkaria.postgresql.org; Thu, 09 Jul 2015 09:00:15 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1ZD7gj-0004Fr-OD for pgsql-performance@postgresql.org; Thu, 09 Jul 2015 09:00:13 +0000 Received: from mail.anarazel.de ([217.115.131.40]) by makus.postgresql.org with esmtp (Exim 4.84) (envelope-from ) id 1ZD7gh-0003iQ-1q for pgsql-performance@postgresql.org; Thu, 09 Jul 2015 09:00:12 +0000 Received: from intern.anarazel.de (p5DDC6245.dip0.t-ipconnect.de [93.220.98.69]) (Authenticated sender: andres@anarazel.de) by mail.anarazel.de (Postfix) with ESMTPSA id B0AEB860002; Thu, 9 Jul 2015 11:00:08 +0200 (CEST) Date: Thu, 9 Jul 2015 11:00:08 +0200 From: Andres Freund To: Tom Lane Cc: Craig James , Merlin Moncure , "Joshua D. Drake" , "Graeme B. Bell" , postgres performance list Subject: Re: Hmmm... why does CPU-intensive pl/pgsql code parallelise so badly when queries parallelise fine? Anyone else seen this? Message-ID: <20150709090008.GV10242@alap3.anarazel.de> References: <6E55113B-FA05-433C-9B21-623F798EE935@skogoglandskap.no> <559CB5BF.2080509@commandprompt.com> <20150708202733.GS10242@alap3.anarazel.de> <20150708224518.GT10242@alap3.anarazel.de> <15702.1436413118@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <15702.1436413118@sss.pgh.pa.us> X-Pg-Spam-Score: -4.5 (----) 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 2015-07-08 23:38:38 -0400, Tom Lane wrote: > andres@anarazel.de (Andres Freund) writes: > > On 2015-07-08 15:38:24 -0700, Craig James wrote: > >> From my admittedly naive point of view, it's hard to see why any of this > >> matters. I have functions that do purely CPU-intensive mathematical > >> calculations ... you could imagine something like is_prime(N) that > >> determines if N is a prime number. I have eight clients that connect to > >> eight backends. Each client issues an SQL command like, "select > >> is_prime(N)" where N is a simple number. > > > I mostly replied to Merlin's general point (additionally in the context of > > plpgsql). > > > But I have a hard time seing that postgres would be the bottleneck for a > > is_prime() function (or something with similar characteristics) that's > > written in C where the average runtime is more than, say, a couple > > thousand cyles. I'd like to see a profile of that. > > But that was not the case that Graeme was complaining about. No, Craig was complaining about that case... > One of my Salesforce colleagues has been looking into ways that we could > decide to skip the per-statement snapshot acquisition even in volatile > functions, if we could be sure that a particular statement isn't going to > do anything that would need a snapshot. Yea, I actually commented about that on IRC as well. I was thinking about actually continuing to get a snapshot, but mark it as 'complete on usage'. I.e. only call GetSnapshotData() only when the snapshot is used to decide about visibility. We probably can't do that in the toplevel visibility case because it'll probably have noticeable semantic effects, but ISTM it should be doable for the volatile function using spi case. -- Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance