pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Joshua D. Drake <jd@commandprompt.com>
To: Craig James <cjames@emolecules.com>
To: Graeme B. Bell <graeme.bell@nibio.no>
Cc: postgres performance list <pgsql-performance@postgresql.org>
Subject: Re: Hmmm... why does CPU-intensive pl/pgsql code parallelise so badly when queries parallelise fine? Anyone else seen this?
Date: Tue, 07 Jul 2015 22:31:43 -0700
Message-ID: <559CB5BF.2080509@commandprompt.com> (raw)
In-Reply-To: <CAFwQ8rcEOiGJ79WtoO=uTX33ZhKVUWG9v8iO14TR+AoT_wd1og@mail.gmail.com>
References: <6E55113B-FA05-433C-9B21-623F798EE935@skogoglandskap.no>
	<CAFwQ8rcEOiGJ79WtoO=uTX33ZhKVUWG9v8iO14TR+AoT_wd1og@mail.gmail.com>
List-Unsubscribe:  <mailto:majordomo@postgresql.org?body=unsub%20pgsql-performance>


On 07/07/2015 08:05 PM, Craig James wrote:
>
>
> No ideas, but I ran into the same thing. I have a set of C/C++ functions
> that put some chemistry calculations into Postgres as extensions (things
> like, "calculate the molecular weight of this molecule"). As SQL
> functions, the whole thing bogged down, and we never got the scalability
> we needed. On our 8-CPU setup, we couldn't get more than 2 CPUs busy at
> the same time, even with dozens of clients.
>
> When I moved these same functions into an Apache fast-CGI HTTP service
> (exact same code, same network overhead), I could easily scale up and
> use the full 100% of all eight CPUs.
>
> I have no idea why, and never investigated further. The convenience of
> having the functions in SQL wasn't that important.

I admit that I haven't read this whole thread but:

Using Apache Fast-CGI, you are going to fork a process for each instance 
of the function being executed and that in turn will use all CPUs up to 
the max available resource.

With PostgreSQL, that isn't going to happen unless you are running (at 
least) 8 functions across 8 connections.

JD

-- 
Command Prompt, Inc. - http://www.commandprompt.com/  503-667-4564
PostgreSQL Centered full stack support, consulting and development.
Announcing "I'm offended" is basically telling the world you can't
control your own emotions, so everyone else should do it for you.


-- 
Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-performance



view thread (23+ messages)  latest in thread

Message-ID: <559CB5BF.2080509@commandprompt.com>
Permalink:  ../559CB5BF.2080509@commandprompt.com/
Also on:    postgresql.org/message-id/559CB5BF.2080509@commandprompt.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: jd@commandprompt.com, cjames@emolecules.com, graeme.bell@nibio.no
  Subject: Re: Hmmm... why does CPU-intensive pl/pgsql code parallelise so badly when queries parallelise fine? Anyone else seen this?
  In-Reply-To: <559CB5BF.2080509@commandprompt.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox