[PyGreSQL] Multi-user and Postgresql

Scott Davis Robert.S.Davis at ivv.nasa.gov
Tue Apr 4 10:10:07 EDT 2000


I am going to make an attempt at expressing my concern over how to
implement transactions multiple inserts into tables and concurrency using
PostgreSql.

I am developing a web based application with PostgreSql as
RDBMS backend.  I have looked around but I am looking for more info on
concurrency and PostgreSql.  I have several tables with unique db keys
that need to stay unique.  If multiple users are executing the same query
that hits multiple tables and inserts rows how do I guarantee that for
instance:

User 1 wants to insert row into table a (has a unique key that needs to
stay unique)

User 2 wants to insert row into table a at same time as User 1.

Does PostgreSql guarantee that the key that is assigned to user 2 through
a sequence for instance is not the same as User 2 key.

Also there is multiple tables that User 1 might insert into and I guess I
need to wrap BEGIN and COMMIT statement around all of the SQL to
guarantee that User 1 and User 2 session is clearly marked.  In
otherwords:

BEGIN
User 1 inserts into table a key is generated
that same key is used by USER 1 in the insert into table 2 and table 2
also has a key generated for it thru a sequence
COMMIT

How do I guarantee that all of the transactions that USER 1 processes
through the life of the CGI executing from web browser are unique and
that USER 2 does not get the same keys via a sequence that USER 1.
I read something about SERIALIZE in PostgreSql but I am not sure about
the application of this or if it is needed.

Any help would be greatly appreciated.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Robert.S.Davis.vcf
Type: text/x-vcard
Size: 362 bytes
Desc: Card for Scott Davis
Url : http://mailman.vex.net/pipermail/pygresql/attachments/20000404/e2bdf482/Robert.S.Davis.vcf


More information about the PyGreSQL mailing list