Trigger working on more than 50 million records
The row being updated by the trigger will be locked until the end of the transaction.  If the same combination of s,c,p,m,e is inserted by two concurrent transactions, one will block until the other commits or rolls back.  If concurrent transactions never touch the same rows, they will not block each other.


  via a pgsql loop


What is that?  Are you talking about PL/pgSQL?  All in one transaction?  If two concurrent transactions are inserting 50,000 rows each, it is almost certain that there is at least one overlap between them.


  run that file in 1 batch


Again, what is that?  psql -f?  Is it just a list of insert, or is it wrapped in BEGIN, COMMIT statements?