Causes an insert into a table with a unique column a tablelock or a rowlock?

Started by u15074about 23 years ago2 messagesgeneral
Jump to latest
#1u15074
u15074@hs-harz.de

I have a table containing a unique (primary key) column.
When I start a transaction and insert a row into the table, that doesn't
violate the unique constraint, will the whole table be locked or will there be
a rowlock?
What happens if I have a parallel transaction running, that inserts the same
row like the other transaction? Will I get an error or will I be able to
continue the transaction, but get an error when trying to commit?

Thanks.

-------------------------------------------------
This mail sent through IMP: http://horde.org/imp/

#2Dennis Gearon
gearond@cvc.net
In reply to: u15074 (#1)
Re: Causes an insert into a table with a unique column

Your new version will coexist with the old version till the point of
committing the transacton ( usually auto happens ). Then some sort of
flag is changed that says the new record is current and the old values
get flagged as not durrent, to be 'vacuumed' at some point.

u15074 wrote:

Show quoted text

I have a table containing a unique (primary key) column.
When I start a transaction and insert a row into the table, that doesn't
violate the unique constraint, will the whole table be locked or will there be
a rowlock?
What happens if I have a parallel transaction running, that inserts the same
row like the other transaction? Will I get an error or will I be able to
continue the transaction, but get an error when trying to commit?

Thanks.

-------------------------------------------------
This mail sent through IMP: http://horde.org/imp/

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

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