Thread safe connection-name mapping in ECPG. Is it required?

From: Shridhar Daithankar <shridhar(at)frodo(dot)hserus(dot)net>
To: "PostgreSQL-development" <pgsql-hackers(at)postgresql(dot)org>
Subject: Thread safe connection-name mapping in ECPG. Is it required?
Date: 2004-02-23 15:57:40
Message-ID: 200402232127.40158.shridhar@frodo.hserus.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi all,

I was just going thr. the ecpg sources checking for thread safety.

It looks like the mutex protects the connections list in connection.c. I do
not like that from a application developers perspective.

If I am developing an application and using multiple connections in multiple
threads, I have to store a connection name for each connection as C string.
Of course, I also have to protect it across thread so that I can rightly tell
ecpg what connection I would be talking to next.

If an application can take care of a C string, it can also take care of a
connection structure. On top of it, it eliminates the list lookup. The
potential performance gain could be worth it if there are hundreds of
connections and a busy website/application server.

What I wonder is, do we really need to maintain that level of lookup? Can't we
just say a connection is a 'struct connection *' which should be opaque and
should not be touched or poked inside, just like PGConn.

Just a thought...

Shridhar

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2004-02-23 16:14:09 Re: Pl/Java - next step?
Previous Message Lamar Owen 2004-02-23 15:38:26 Re: Heads up: 7.3.6 and 7.4.2 coming soon