473,788 Members | 2,726 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

table locking.. FK tables locking on insert

I have several tables with common FKs.. the problem occurs when
performing a large number of inserts on any of the tables at the same
time. The first to start inserting seems to get a lock on the
referenced FK tables and doesn't release them until its done, forcing
the other apps to just wait... and wait..since they also seem to want a
lock for their FK tables..... something just doesnt seem right here :(

when I remove the FKs, everything goes fine.. but I need my foreign
keys.. really I do.

What does postgres do here? or is the problem in the jdbc driver.. or
maybe the server? (using Jboss 3.2.1, hibernate and 7.3.2 postgres)..

any ideas?
---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html

Nov 12 '05 #1
4 3105

On Tue, 28 Oct 2003, Ati Rosselet wrote:
I have several tables with common FKs.. the problem occurs when
performing a large number of inserts on any of the tables at the same
time. The first to start inserting seems to get a lock on the
referenced FK tables and doesn't release them until its done, forcing
the other apps to just wait... and wait..since they also seem to want a
lock for their FK tables..... something just doesnt seem right here :(

when I remove the FKs, everything goes fine.. but I need my foreign
keys.. really I do.

What does postgres do here? or is the problem in the jdbc driver.. or
maybe the server? (using Jboss 3.2.1, hibernate and 7.3.2 postgres)..

any ideas?


A lock is grabbed on the associated pk row (so that some other transaction
can't delete it). Unfortunately that lock conflicts with other fk
modifications attempting to grab the lock. Two possible solutions involve
read locks or dirty reads. Neither of these is trivial, one will get
implemented eventually, but there's no concrete timetable.

For more details, you may want to look up info in the archives.

---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to ma*******@postg resql.org

Nov 12 '05 #2
Stephan Szabo wrote:
On Tue, 28 Oct 2003, Ati Rosselet wrote:
I have several tables with common FKs.. the problem occurs when
performing a large number of inserts on any of the tables at the same
time. The first to start inserting seems to get a lock on the
referenced FK tables and doesn't release them until its done, forcing
the other apps to just wait... and wait..since they also seem to want a
lock for their FK tables..... something just doesnt seem right here :(

when I remove the FKs, everything goes fine.. but I need my foreign
keys.. really I do.

What does postgres do here? or is the problem in the jdbc driver.. or
maybe the server? (using Jboss 3.2.1, hibernate and 7.3.2 postgres)..

any ideas?


A lock is grabbed on the associated pk row (so that some other transaction
can't delete it). Unfortunately that lock conflicts with other fk
modifications attempting to grab the lock. Two possible solutions involve
read locks or dirty reads. Neither of these is trivial, one will get
implemented eventually, but there's no concrete timetable.

For more details, you may want to look up info in the archives.


This problem is fixed for v7.4 and backpatched into v7.3.4. There will
be a 7.3.5 release shortly that fixes a possible foreign key violation
related to deferred checking due to this change. So you might want to
wait for 7.3.5.
Jan

--
#============== =============== =============== =============== ===========#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me. #
#============== =============== =============== ====== Ja******@Yahoo. com #
---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match

Nov 12 '05 #3

On Mon, 3 Nov 2003, Jan Wieck wrote:
Stephan Szabo wrote:
On Tue, 28 Oct 2003, Ati Rosselet wrote:
I have several tables with common FKs.. the problem occurs when
performing a large number of inserts on any of the tables at the same
time. The first to start inserting seems to get a lock on the
referenced FK tables and doesn't release them until its done, forcing
the other apps to just wait... and wait..since they also seem to want a
lock for their FK tables..... something just doesnt seem right here :(

when I remove the FKs, everything goes fine.. but I need my foreign
keys.. really I do.

What does postgres do here? or is the problem in the jdbc driver.. or
maybe the server? (using Jboss 3.2.1, hibernate and 7.3.2 postgres)..

any ideas?


A lock is grabbed on the associated pk row (so that some other transaction
can't delete it). Unfortunately that lock conflicts with other fk
modifications attempting to grab the lock. Two possible solutions involve
read locks or dirty reads. Neither of these is trivial, one will get
implemented eventually, but there's no concrete timetable.

For more details, you may want to look up info in the archives.


This problem is fixed for v7.4 and backpatched into v7.3.4. There will


Are you sure, Jan? His problem seems to be related to inserts which AFAIK
still run the for update queries that might lock against other inserting
transactions as opposed to the update problems that I think that patch
fixed.

---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html

Nov 12 '05 #4
Stephan Szabo wrote:
On Mon, 3 Nov 2003, Jan Wieck wrote:
Stephan Szabo wrote:
> On Tue, 28 Oct 2003, Ati Rosselet wrote:
>
>> I have several tables with common FKs.. the problem occurs when
>> performing a large number of inserts on any of the tables at the same
>> time. The first to start inserting seems to get a lock on the
>> referenced FK tables and doesn't release them until its done, forcing
>> the other apps to just wait... and wait..since they also seem to want a
>> lock for their FK tables..... something just doesnt seem right here :(
>>
>> when I remove the FKs, everything goes fine.. but I need my foreign
>> keys.. really I do.
>>
>> What does postgres do here? or is the problem in the jdbc driver.. or
>> maybe the server? (using Jboss 3.2.1, hibernate and 7.3.2 postgres)..
>>
>> any ideas?
>
> A lock is grabbed on the associated pk row (so that some other transaction
> can't delete it). Unfortunately that lock conflicts with other fk
> modifications attempting to grab the lock. Two possible solutions involve
> read locks or dirty reads. Neither of these is trivial, one will get
> implemented eventually, but there's no concrete timetable.
>
> For more details, you may want to look up info in the archives.


This problem is fixed for v7.4 and backpatched into v7.3.4. There will


Are you sure, Jan? His problem seems to be related to inserts which AFAIK
still run the for update queries that might lock against other inserting
transactions as opposed to the update problems that I think that patch
fixed.


Hmmm ... er ... you're right. His only option currently is deferring the
check then. I think we really need read locks someday.
Jan

--
#============== =============== =============== =============== ===========#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me. #
#============== =============== =============== ====== Ja******@Yahoo. com #
---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

Nov 12 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1504
by: Jacob Nielsen | last post by:
Hi, I've got two tables that control my menu on my site (which is coded in ASP). The first table (cam_menu) contains info about the sort order of the menu and the second about my content. To insert a menuitem above a previous menuitem I use these SQL-sentences: '## Select id to insert new menuitem above strSelectidSQL = "SELECT * FROM cam_menu WHERE id = " & intActionid & "" Set SelectidRS = Conn.Execute(strSelectidSQL)
3
2526
by: Albretch | last post by:
I am trying to insert some textual data belonging to an HTML page into a table column with 'TEXT' as data type mysql's maual _/manual.html#String_types tell you, you may insert up to (2^16 - 1), that is 65535 characters, but I am getting errors when I try to insert a column larger than 236 characters. Initially I thought it might be because I had to escape some characters, but after playing a some scenarios and just inserting a bunch...
3
6091
by: mahajan.sanjeev | last post by:
Hi All, I am using a SQLTransaction to insert records into a table. At one time, there are 5000 or more records to be inserted one by one. It takes some 20-25 mins for the entire process to run. Another application accesses the same table. As long as the insert process within the transaction isn't completed, the second application is not getting any response from the server. I
22
4235
by: EMW | last post by:
Hi, I managed to create a SQL server database and a table in it. The table is empty and that brings me to my next chalenge: How can I get the info in the table in the dataset to go in an empty SQL table? Is there a short way like the FILL method to get data into the dataset or do I have to read each datarow in the table and write it one at the time to the
5
7191
by: Gavin Scott | last post by:
Hi, I'm having a performance problem with a large database table we use with postgres 7.3.4. The table is: db=> \d log Table "public.log" Column | Type | Modifiers ---------+----------+----------- hid | integer |
2
1178
by: invinfo | last post by:
I don't recall exactly what options I selected in September when I installed the beta v5.0.4 on my development machine, But, as I started to develop and then backup data, I noticed that my tables are all using the storage engine: InnoDB. Can someone jog my memory and tell me what options cause that to be the default ? I'm on the fence, b/w choosing MyISAM and InnoDB - I don't think I'll be using any transactions or foreign keys, in my...
22
18814
by: RayPower | last post by:
I'm having problem with using DAO recordset to append record into a table and subsequent code to update other tables in a transaction. The MDB is Access 2000 with the latest service pack of JET 4. The system is client/server, multiusers based. The MDBs are using record locking. Here is part of the code: Dim wkSpace As Workspace, db As Database Dim rstTrans As DAO.Recordset Set wkSpace = DBEngine.Workspaces(0)
0
2306
by: shakahshakah | last post by:
Just started investigating InnoDB after having used MyISAM tables in the 4.0.12 version, almost immediately ran into a locking issue with INSERTs, DELETEs, and transactions. Given the following table: CREATE TABLE test1 ( f1 varchar(32) default NULL ) and a steady stream of INSERTs from a command-line shell:
7
1855
dlite922
by: dlite922 | last post by:
I need to do some sort of Locking mechanism at interface level, instead of DB Level. I know how MySQL table locking works, but that won't work in my scenerio. Requirements: When someone is editing a case, for example changing the persons info, editing the violations/charges they have, etc... I don't want another user to have pulled the same case and one of them clicks Update or Save before the other. So the case is locked for...
0
9656
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9498
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10175
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8993
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6750
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5399
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4070
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3675
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2894
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.