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

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/


Re: Causes an insert into a table with a unique column

From
Dennis Gearon
Date:
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:
> 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
>