From: Stephen Frost <sfrost@snowman.net>
To: Eliot Gable <egable+pgsql-performance@gmail.com>
Cc: pgsql-performance@postgresql.org
Subject: Re: PostgreSQL Function Language Performance: C vs PL/PGSQL
Date: Wed, 26 May 2010 12:32:51 -0400
Message-ID: <20100526163251.GB21875@tamriel.snowman.net> (raw)
In-Reply-To: <AANLkTilqE1ODTmCtAqY6oUDnSYruapc6UdO0_ROf1-li@mail.gmail.com>
References: <AANLkTinPXHz0GMP6J6eWksip54AiCImJVNO4Yf4vzFm4@mail.gmail.com>
<20100526161839.GA21875@tamriel.snowman.net>
<AANLkTilqE1ODTmCtAqY6oUDnSYruapc6UdO0_ROf1-li@mail.gmail.com>
* Eliot Gable (egable+pgsql-performance@gmail.com) wrote:
> Thanks for the quick follow-up. So, you are saying that if I can do SPI in
> _PG_init, then I could prepare all my queries there and they would be
> prepared once for the entire function when it is loaded? That would
> certainly achieve what I want. Does anybody know whether I can do SPI in
> _PG_init?
Unless you're using EXECUTE in your pl/pgsql, the queries in your
pl/pgsql function are already getting prepared on the first call of the
function for a given backend connection.. If you're using EXECUTE in
pl/gpsql then your problem might be planning time. Moving that to C
isn't going to change things as much as you might hope if you still have
to plan the query every time you call it..
> The function gets called a lot, but not in the same transaction. It is only
> called once per transaction.
That's not really relevant.. Is it called alot from the same
backend/database connection? If so, and if you're using regular SELECT
statements and the like (not EXECUTE), then they're getting prepared the
first time they're used and that is kept across transactions.
Thanks,
Stephen
Attachments:
signature.asc (application/pgp-signature, 196B) download
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: sfrost@snowman.net, egable+pgsql-performance@gmail.com
Subject: Re: PostgreSQL Function Language Performance: C vs PL/PGSQL
In-Reply-To: <20100526163251.GB21875@tamriel.snowman.net>
* 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