Re: [SQL] Reading and writing at the same time

From: Herouth Maoz <herouth(at)oumail(dot)openu(dot)ac(dot)il>
To: "G(dot) Anthony Reina" <reina(at)nsi(dot)edu>
Cc: pgsql-general(at)postgreSQL(dot)org
Subject: Re: [SQL] Reading and writing at the same time
Date: 1998-10-25 09:49:03
Message-ID: l03110701b258a3995c0e@[147.233.159.109]
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-sql

(Redirected from SQL list to GENERAL list)

At 20:57 +0200 on 23/10/98, G. Anthony Reina wrote:

> I know that Postgres has table-level locking so that once a write is
> being performed on a table, no other reads or writes can be performed
> until that write finishes.
>
> I have a C program that performs several updates and inserts to a table.
> I found that I am able, despite any table locking, to use the front-end
> psql program at the same time to select data from the same table that is
> being written to. So in essence, I am able to have one program that is
> writing while at the same time another program reads (without running
> into aborted backends).

Are you sure you interpret what you see correctly? The backend in fact
locks out any readers while updates take place. I have a hunch that you did
not declare a transaction in your C program, and thus, each of the updates
ani inserts in it is a separate transaction.

When that happens, the reads (from your psql frontend) and the writes (from
your C) are interspersed, because the lock only holds while a transaction
is active. The next update in your C program may wait until the read in
PSQL has been done.

Herouth

--
Herouth Maoz, Internet developer.
Open University of Israel - Telem project
http://telem.openu.ac.il/~herutma

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Luc Lalonde 1998-10-25 18:11:05 (no subject)
Previous Message Moises Flores 1998-10-24 19:24:47 i need information for prostgress sql

Browse pgsql-sql by date

  From Date Subject
Next Message Michael Olivier 1998-10-26 05:13:18 palloc failure: memory exhausted, but ulimit 'unlimited'
Previous Message Leslie Mikesell 1998-10-24 17:37:42 varchar vs. text