title: Concurrent database (PostgreSQL) commands in the same transaction
body: <p>I'm writing a .NET 4 application that imports a large amount of data from a file into a PostgreSQL 9.1 database. Profiling shows that the DB calls to actually INSERT the data take up over 90% of the time. The DB server appears to be CPU-bound - using all of one CPU.</p>
  
  <p>If possible, I'd like to import the data faster by using all the CPUs. The input file could be broken up into pieces on the client, so this normally wouldn't be too hard, but I want to ensure that if any errors occur in importing a file then the DB is not modified at all. To accomplish this I'm doing the entire import in one transaction.</p>
  
  <p>Is it possible to somehow send concurrent commands to the DB server (to utilise all of its CPUs), but still ensure that either the entire import succeeds or no changes are made? As far as I understand a transaction cannot be used from multiple threads to run multiple commands concurrently, can it? I'm using Npgsql as the ADO.NET provider, if that makes a difference.</p>