Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id B7DAC6325E1 for ; Wed, 26 May 2010 14:09:53 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 49879-05 for ; Wed, 26 May 2010 17:09:46 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mail-pz0-f183.google.com (mail-pz0-f183.google.com [209.85.222.183]) by mail.postgresql.org (Postfix) with ESMTP id 2FD3D63222E for ; Wed, 26 May 2010 14:09:45 -0300 (ADT) Received: by pzk13 with SMTP id 13so5052123pzk.13 for ; Wed, 26 May 2010 10:09:44 -0700 (PDT) Received: by 10.141.22.18 with SMTP id z18mr6903607rvi.22.1274893784392; Wed, 26 May 2010 10:09:44 -0700 (PDT) Received: from Craig-Jamess-MacBook-Pro.local (wsip-70-167-124-126.sd.sd.cox.net [70.167.124.126]) by mx.google.com with ESMTPS id i19sm239759rvn.11.2010.05.26.10.09.42 (version=SSLv3 cipher=RC4-MD5); Wed, 26 May 2010 10:09:43 -0700 (PDT) Message-ID: <4BFD55D5.4040907@emolecules.com> Date: Wed, 26 May 2010 10:09:41 -0700 From: Craig James User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.1.9) Gecko/20100317 Thunderbird/3.0.4 MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: Re: PostgreSQL Function Language Performance: C vs PL/PGSQL References: <20100526161839.GA21875@tamriel.snowman.net> <20100526163251.GB21875@tamriel.snowman.net> <20100526164716.GC21875@tamriel.snowman.net> In-Reply-To: <20100526164716.GC21875@tamriel.snowman.net> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.9 tagged_above=-10 required=5 tests=BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001 X-Spam-Level: X-Archive-Number: 201005/207 X-Sequence-Number: 38791 On 5/26/10 9:47 AM, Stephen Frost wrote: > * Eliot Gable (egable+pgsql-performance@gmail.com) wrote: >> Since PostgreSQL is written in C, I assume there is no >> such additional overhead. I assume that the PL/PGSQL implementation at its >> heart also uses SPI to perform those executions. Is that a fair statement? > > Right, but I also wouldn't expect a huge improvment either, unless > you're calling these queries a ton, or the queries that you're calling > from the pl/pgsql are pretty short-lived. > > Don't get me wrong, C is going to be faster, but it depends on exactly > what's going on as to if it's going to be an overall improvment of, say, > 10%, or a 10-fold improvment. :) Or a 0.1% improvement, which is more likely. Or that the PL/PGSQL version is even faster than the C version, because if you do any string regexp in your function, Perl has extremely efficient algorithms, probably better than you have time to write in C. We use Perl extensively and have never had any complaints. The database activity completely dominates all queries, and the performance of Perl has never even been noticable. We use a C functions for a few things, and it is a big nuisance. Every time you upgrade Postgres or your OS, there's a chance the recompile will fail because of changed header files. Any bugs in your code crash Postgres itself. We avoid C as much as possible (and I love C, been doing it since 1984). Craig