Skip site navigation (1) Skip section navigation (2)

Peripheral Links

Header And Logo

PostgreSQL
| The world's most advanced open source database.

Site Navigation

Search for
  Advanced Search

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(at)frostconsultingllc(dot)com>
Frost Consulting, LLC 	http://www.frostconsultingllc.com/
Phone: 650-780-7908	FAX: 650-649-1954



Home | Main Index | Thread Index

Privacy Policy | PostgreSQL Archives hosted by Command Prompt, Inc. | Designed by tinysofa
Copyright © 1996 – 2008 PostgreSQL Global Development Group