I understand that PostgreSQL inserts use ROW EXCLUSIVE locks, does that mean that inserts can be in parallel, and that one insert won't lock up the entire table?
Table in question has a primary key generated outside of DB and no additional indexes (but I'm curious what would happen if that wasn't the case).
Edit 1:
Per documentation, ROW EXCLUSIVE conflicts with SHARE which is acquired by CREATE INDEX.
Does this mean that if the table has index, insert will lock up the entire table?
Or will the table be locked only when creating the index first time?
Also, as I understand now, primary key is also an index, right?
ROW EXCLUSIVEis is badly named, as the docs explain. As for the lock taken forCREATE INDEX... that's for theCREATE INDEXcommand, not for the work done to update an index as part of anINSERTorUPDATEcommand. You can have as many non-unique indexes as you like and still get concurrent inserts - though each added index requires more work to be done for each insert and will slow every insert down a bit. - Craig Ringer