Oracle FAQ Your Portal to the Oracle Knowledge Grid

Home -> Community -> Usenet -> c.d.o.server -> Re: REF column and index

Re: REF column and index

From: Asya Kamsky <>
Date: 9 Jul 2004 10:34:09 -0700
Message-ID: <>

"Howard J. Rogers" <> wrote in message news:<40e017e8$0$18190$>...
> "Kalmact" <> wrote in message
> >It may not be desirable in case of high data volumes even though
> > you do not do any DML on the parent.
> > Also I think 9i onwards the child table is locked only for the
> > duration of the execution of the DML statement rather than the whole
> > transaction.
> Oh dear. Tell me you haven't bought into that hoary old myth that says the
> foreign key locking issue has gone away in 9i? It isn't true. Yes, the
> update on the parent will release the lock on the child table fairly
> immediately, *assuming it has managed to acquire it in the first place*. But
> if there is pre-existing DML on the child table, then the parent DML will
> not be able to acquire the lock it needs in the first place. It will
> therefore hang, waiting for it. And *every other piece of CHILD table DML
> will queue up behind it*. The locking issues in 9i are just as bad as they
> ever were in 8i or earlier, and it is only marketing hype that ever
> suggested otherwise.

I'm trying to deal with exactly this problem. I have a transaction which makes an insert into the parent table, and in the process acquires shared read locks on every child table that has a foreign constraint to it. Every one of those tables has an index on that foreign key so I'm not sure why this is happening. My best guess is that locks are acquired in the wrong order so that the inserting transaction can't insert because there's a read lock and the read lock won't be released till the insert completes... So I have a deadlock (which goes undetected, by the way).

Is there a workaround for this? The only things I find on this subject all imply that having the index on the foreign key column should make the problem go away.

Asya Received on Fri Jul 09 2004 - 12:34:09 CDT

Original text of this message