Re: SELECT FOR UPDATE

From: Jan Wieck <JanWieck(at)Yahoo(dot)com>
To: Oliver Elphick <olly(at)lfix(dot)co(dot)uk>
Cc: Jan Wieck <JanWieck(at)Yahoo(dot)com>, Postgres <pgsql-general(at)postgresql(dot)org>
Subject: Re: SELECT FOR UPDATE
Date: 2001-08-23 14:09:19
Message-ID: 200108231409.f7NE9JL01456@jupiter.us.greatbridge.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Oliver Elphick wrote:
> Jan Wieck wrote:
> > But the question itself tells that you're about to implement
> > a major design error in your application. Holding database
> > locks during user interaction IS A BAD THING. Never, never
> > ever do it that way. And anybody telling you something
> > different is an overpaid idiot.
>
> I can see arguments to support this view, but consider this classic
> scenario:
>
> User1: Read data into an interactive program
> User1: Start to make changes
> User2: Read data into an interactive program
> User2: Start to make changes
> User1: Save changes
> User2: Save changes

All ERP systems I know deal with that issue by inserting and
deleting some advisory lock information in another table.
Let's say you want to change customers 4711 address. Before
letting you do so on the edit screen, the application tries
to insert "CUST.4711" into a central lock table. Now this
thing has a unique index on that field, so if someone else is
already editing 4711, it'll fail and the application can tell
you so and won't let you do the same.

AFAIK it's the only way to deal with that problem. Think
about scaling as well. No enterprise class software has a DB
connection per interactive user. They all have some sort of
DB-middletear-presentation model where many users share a few
DB connections.

Jan

--

#======================================================================#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me. #
#================================================== JanWieck(at)Yahoo(dot)com #

_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Mike Mascari 2001-08-23 14:16:43 SQL Debugging Aide
Previous Message Jan Wieck 2001-08-23 13:55:37 Re: protected ON DELETE CASCADE