Unix Technical Forum

updating table with foreign keys cause locking of referenced row/table?

This is a discussion on updating table with foreign keys cause locking of referenced row/table? within the pgsql Admins forums, part of the PostgreSQL category; --> Postgresql-8.3.1 I have a plpgsql function which is called nightly to update rows in a summary table. The summary ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > pgsql Admins

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-11-2008, 01:53 AM
Jeff Frost
 
Posts: n/a
Default updating table with foreign keys cause locking of referenced row/table?

Postgresql-8.3.1

I have a plpgsql function which is called nightly to update rows in a summary
table. The summary table has foreign keys that reference the users table.
When the nightly job runs, the users table gets locked such that UPDATES to
the user table are stuck waiting on the transactionid of the function.

The function does not update or select for update any rows in the users table
and removing the foreign keys in the summary table allows the UPDATES of the
users table to happen with no problem.

Interestingly, in testing this, I started a transaction, updated a bunch of
rows in the summary table with UPDATE, left the transaction open, started
a new session and successfully updated rows in the users table that are
pointed to by the updated rows in the summary table. So there doesn't seem to
be a locking problem outside of the function.

Is the locking behavior different inside a plpgsql function?

--
Jeff Frost, Owner <jeff@frostconsultingllc.com>
Frost Consulting, LLC http://www.frostconsultingllc.com/
Phone: 650-780-7908 FAX: 650-649-1954

--
Sent via pgsql-admin mailing list (pgsql-admin@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-admin

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 11:58 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com