Re: Persistent data per connection

From: "Joshua D(dot) Drake" <jd(at)commandprompt(dot)com>
To: Jeff Amiel <jamiel(at)istreamimaging(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Persistent data per connection
Date: 2005-03-25 17:23:53
Message-ID: 1111771433.5025.25.camel@jd2.commandprompt.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


> Our latest scheme involves giving each web system user a postgresql user
> account and when we grab a connection from the connection pool, we SET
> SESSION AUTHORIZATION for that user. We can then access the user info
> from the trigger.
>
> But is there a better/different way to persist data at the connection level?

You could create a series of events that happen on the initial
connection object. For example:

New Connection
Check if new connection
select foo from table
if foo
continue

If foo returns you already have all your predefined information such as
cursors etc...

If foo does not return

New Connection
Check if new connection
select foo from table
!if foo
create temp table foo
insert into foo
declare cursor
set
etc...
continue

The table would be a temp table which will automatically drop if the
connection drops so you know if it is a new connection.

You could use pgPool to manage the persistent connections themselves.

This will put more overhead on the startup of new connections but
as the site because busier you will have less and less new connections
and more re-used connections.

Sincerely,

Joshua D. Drake

>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to majordomo(at)postgresql(dot)org
--
Command Prompt, Inc., Your PostgreSQL solutions company. 503-667-4564
Custom programming, 24x7 support, managed services, and hosting
Open Source Authors: plPHP, pgManage, Co-Authors: plPerlNG
Reliable replication, Mammoth Replicator - http://www.commandprompt.com/

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Steve Atkins 2005-03-25 17:41:08 Re: Persistent data per connection
Previous Message Jeff Amiel 2005-03-25 16:56:50 Re: Persistent data per connection