Re: Pl/Perl function: Speed of the First time executing pl/perl function in connection;

From: Hannu Krosing <hannu(at)krosing(dot)net>
To: Oleg Serov <serovov(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Andrew Dunstan <andrew(at)dunslane(dot)net>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Pl/Perl function: Speed of the First time executing pl/perl function in connection;
Date: 2008-11-17 17:31:16
Message-ID: 1226943076.11131.18.camel@huvostro
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sun, 2008-11-16 at 23:20 +0300, Oleg Serov wrote:
> Wee need to use shared memory for passing one BIGINT value(is session
> throwout triggers), can you advice the method to get/set it with best
> performance ?

have you tried "setval(seq, value)" to set and "select last_value from
seq" to read it.

or just use a table, if concurrency control is important

hannu=# create table shvaltable(id int, value bigint);
CREATE TABLE
Time: 34.704 ms
hannu=# insert into shvaltable values(1,0);
INSERT 0 1
Time: 0.742 ms
hannu=# explain analyse update shvaltable set value=47 where id=1;
QUERY
PLAN
-------------------------------------------------------------------------------------------------------
Seq Scan on shvaltable (cost=0.00..34.25 rows=10 width=10) (actual
time=0.015..0.017 rows=1 loops=1)
Filter: (id = 1)
Total runtime: 0.073 ms
(3 rows)

Time: 3.503 ms
hannu=# explain analyse update shvaltable set value=47 where id=1;
QUERY
PLAN
-------------------------------------------------------------------------------------------------------
Seq Scan on shvaltable (cost=0.00..34.25 rows=10 width=10) (actual
time=0.014..0.016 rows=1 loops=1)
Filter: (id = 1)
Total runtime: 0.058 ms
(3 rows)

Time: 3.298 ms

> 2008/11/16 Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>:
> > "Oleg Serov" <serovov(at)gmail(dot)com> writes:
> >> So, how i must optimize it?
> >
> > The short-term answer seems to be "preload and use plperlu".
> >
> > regards, tom lane
> >
>

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrew Dunstan 2008-11-17 17:31:55 Re: Pl/Perl function: Speed of the First time executing pl/perl function in connection;
Previous Message Tom Lane 2008-11-17 17:22:09 Re: Pl/Perl function: Speed of the First time executing pl/perl function in connection;