473,385 Members | 1,736 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

insert waiting

Hi,

after some more debugging I found that my application does on average 3
inserts per second. Which is not very fast, but fast enough for now. But
now and then the whole insert proces will be stalled and drop to 0.1
inserts per second. In the output of "ps aux Op" I see postgres in the
state "INSERT WAITING".

I have some other insert/update process running, but not on the same
table. I am absolutely sure, that my insert process is the only one
working on that table.

Can foreign keys block inserts?

TIA

Ulrich
---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

Nov 23 '05 #1
5 2873
I believe foreign key constraints take an exclusive lock on the parent.
If you are inserting two child records that reference the same parent
(at the same time) one insert will block.

John Sidney-Woollett

Ulrich Wisser wrote:
Hi,

after some more debugging I found that my application does on average 3
inserts per second. Which is not very fast, but fast enough for now. But
now and then the whole insert proces will be stalled and drop to 0.1
inserts per second. In the output of "ps aux Op" I see postgres in the
state "INSERT WAITING".

I have some other insert/update process running, but not on the same
table. I am absolutely sure, that my insert process is the only one
working on that table.

Can foreign keys block inserts?

TIA

Ulrich
---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster


---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

Nov 23 '05 #2
Hi John,

but how long is the exclusive lock taken? For the whole transaction?
My jobs are quite big, and transactions usually take several minutes.
I can not afford have all my other jobs stalled for that time.

Ulrich
I believe foreign key constraints take an exclusive lock on the parent.
If you are inserting two child records that reference the same parent
(at the same time) one insert will block.

John Sidney-Woollett

Ulrich Wisser wrote:
Hi,

after some more debugging I found that my application does on average
3 inserts per second. Which is not very fast, but fast enough for now.
But now and then the whole insert proces will be stalled and drop to
0.1 inserts per second. In the output of "ps aux Op" I see postgres in
the state "INSERT WAITING".

I have some other insert/update process running, but not on the same
table. I am absolutely sure, that my insert process is the only one
working on that table.

Can foreign keys block inserts?

TIA

Ulrich
---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster


---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org

Nov 23 '05 #3
On Fri, Aug 20, 2004 at 13:20:49 +0200,
Ulrich Wisser <ul***********@relevanttraffic.se> wrote:
Hi John,

but how long is the exclusive lock taken? For the whole transaction?
My jobs are quite big, and transactions usually take several minutes.
I can not afford have all my other jobs stalled for that time.


Once a lock is taken by a transaction, it is held until the end of that
transaction.

---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org

Nov 23 '05 #4
Ulrich

Either remove the referential integrity constraint, or ask the list if
there is likely to be a way to make the lock non-exclusive, or some
other workaround.

I know that this has been mentioned as an issue before, and I can't
remember what the solution was.

John Sidney-Woollett

Ulrich Wisser wrote:
Hi John,

but how long is the exclusive lock taken? For the whole transaction?
My jobs are quite big, and transactions usually take several minutes.
I can not afford have all my other jobs stalled for that time.

Ulrich
I believe foreign key constraints take an exclusive lock on the
parent. If you are inserting two child records that reference the same
parent (at the same time) one insert will block.

John Sidney-Woollett

Ulrich Wisser wrote:
Hi,

after some more debugging I found that my application does on average
3 inserts per second. Which is not very fast, but fast enough for
now. But now and then the whole insert proces will be stalled and
drop to 0.1 inserts per second. In the output of "ps aux Op" I see
postgres in the state "INSERT WAITING".

I have some other insert/update process running, but not on the same
table. I am absolutely sure, that my insert process is the only one
working on that table.

Can foreign keys block inserts?

TIA

Ulrich
---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster



---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org


---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to ma*******@postgresql.org)

Nov 23 '05 #5

On Fri, 20 Aug 2004, Ulrich Wisser wrote:
but how long is the exclusive lock taken? For the whole transaction?
Until transaction end.
My jobs are quite big, and transactions usually take several minutes.
I can not afford have all my other jobs stalled for that time.


Generally right now your options are:
Remove the constraint
Edit the code to remove the FOR UPDATE clauses used in the constraint
Defer the constraint (thus the locks are only taken at the end for
pretty much the time to check the constraints). This however means
that you're accumulating the deferred constraint information which
takes RAM.

None of these are complete fixes. The complete fix is changing the
constraint to use a different locking mechanism (that doesn't currently
exist). Another partial fix that's been described to me would be to see if
strengthening the locks on actions on the referenced table would allow
weakening of the locks on the referencing table.

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

Nov 23 '05 #6

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

Similar topics

0
by: Rajesh Kapur | last post by:
I have a master slave configuration on linux machines running MySQL 4.0.21. Once every hour, a process deletes about 9000 rows and re-inserts fresh data on the master. The master process completes...
10
by: florian | last post by:
Hi, we have a contention problem because of an application which tries to insert a duplicate row in a table with primary key. This insert fails of course but the locks are not released within...
5
by: Florence HENRY | last post by:
Hello, well, almost everything is in the subject ! I have to fill 2 tables (more complicated than in the example !): CREATE TABLE A ( id serial primary key, foo text);
1
by: Edwin Grubbs | last post by:
Hello, I have experienced problems with postgres hanging when two inserts reference the same foreign key. It appears that the second insert is waiting for the first insert to release a lock....
8
by: shenanwei | last post by:
I have 2 same windows machine, same instance configure and Database , all run DB2 UDB V8.1.5 Test 1 : create table OUT_1 (LINE VARCHAR(350), LINENUMBER INTEGER NOT NULL GENERATED ALWAYS AS...
46
by: dunleav1 | last post by:
I have a process that does inserts that runs 50% slower that Oracle and Mssql. Queries normally take 50% slower than normal. DB2, Oracle, Mssql all are configured on same os, same disk array...
3
by: mahajanvit | last post by:
Hi one and all I got this problem during my project. So in order to solve this I made a very small application. I am trying to insert using SP and sqldatasource control. I know that while using...
8
by: Red | last post by:
If auto-format is turned off in VS2008, there is apparently no way to indent a line. Under Tools->Options->Text Editor->C#->Formatting, there are three checkboxes. Unchecking those seems to cause...
1
oranoos3000
by: oranoos3000 | last post by:
hi i have an error with enter record to table in database(mysql) structure of my table is as follow - phpMyAdmin SQL Dump -- version 2.11.6 -- http://www.phpmyadmin.net -- -- Host:...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...

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.