From: | Anupama Ramaswamy <anumr_0123(at)yahoo(dot)com> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | plperl - caching prepared queries and cleanup |
Date: | 2010-12-16 09:54:29 |
Message-ID: | 538517.30458.qm@web31603.mail.mud.yahoo.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hi,
I am trying to use plperl for one of my triggers. The trigger executes a query.
So I am preparing the query and caching it as below:
if (!defined $_SHARED{'base_table_query'}) {
my $base_columns_query = "select column_name from
information_schema.columns where
table_schema = '$_TD->{table_schema}'
and table_name = \$1";
$_SHARED{'base_table_query'} = spi_prepare($base_columns_query,
'text');
}
$result = spi_exec_prepared($_SHARED{'base_table_query'},
$base_table_name);
Now, in a batch update (involving 1000s of records), the trigger itself fires
for each update.
I will get maximum performance benefit, if I can keep the prepared query in the
global cache across trigger invocation.
In effect, there is no logical point to call spi_freeplan()
Will the plan be freed when the db session / connection closes
Will it lead to any memory leaks (typically my db connections are open for long
time ) ?
Thanks
Anupama.
From | Date | Subject | |
---|---|---|---|
Next Message | Florian Pflug | 2010-12-16 10:03:36 | Re: [HACKERS] getting composite types info from libpq |
Previous Message | Anupama | 2010-12-16 08:57:15 | Plperl caching prepared queries and cleanup |