Thread: table insert/primary key question

table insert/primary key question

From
Scot Kreienkamp
Date:

Hey everyone,

 

I have a table like so:

 

Receiptlimitid: BIGINT (Primary Key)

Profitcenterid: BIGINT

Receiptnumber: INTEGER

 

All are set to Not Null also.

 

 

My question is, if I have an insert that goes idle in transaction for a while before it commits, will it stop all other inserts from happening on the table?  If so, is that because of the possible violation of the primary key by the following pending inserts?  Just trying to confirm the behavior I'm seeing and make sure I understand what's going on. 

 

Thanks!

 


Scot Kreienkamp | Senior Systems Engineer | La-Z-Boy Incorporated ®
1284 North Telegraph Road | Monroe, Michigan 48162 |   Phone: 734-384-6403  |    Fax:  |   Email: SKreien@la-z-boy.com




This message is intended only for the individual or entity to which it is addressed. It may contain privileged, confidential information which is exempt from disclosure under applicable laws. If you are not the intended recipient, please note that you are strictly prohibited from disseminating or distributing this information (other than to the intended recipient) or copying this information. If you have received this communication in error, please notify us immediately by e-mail or by telephone at the above number. Thank you.

Re: table insert/primary key question

From
Albe Laurenz
Date:
Scot Kreienkamp wrote:
> I have a table like so:
> 
> Receiptlimitid: BIGINT (Primary Key)
> Profitcenterid: BIGINT
> Receiptnumber: INTEGER
> 
> All are set to Not Null also.
> 
> 
> My question is, if I have an insert that goes idle in transaction for a while before it commits, will
> it stop all other inserts from happening on the table?  If so, is that because of the possible
> violation of the primary key by the following pending inserts?  Just trying to confirm the behavior
> I'm seeing and make sure I understand what's going on.

Other INSERTs shouldn't be blocked unless you try to insert
a record with the same primary key as the one in the open transaction.

If you experience any such problems, check pg_locks for what's
going on.  Are there any foreign keys involved?

Yours,
Laurenz Albe