title: DB2 Union all vs Parallel run
body: <p>We have separate Databases in DB2 for each customer but with same table structure in each of them. For a .Net Application I need to scan all the databases and show result for the matching entries to the user. I was wondering would it be faster to do a UNION ALL for all the databases or run each query in parallel and then combine them from my .Net Application. </p>
  
  <pre><code>Select EmpName, EmpSal, EmpDate
  from A.Emptable
  where EmpDate &gt; '2015-01-01'
  UNION ALL
  Select EmpName, EmpSal, EmpDate
  from B.Emptable
  where EmpDate &gt; '2015-01-01'
  UNION ALL 
  Select EmpName, EmpSal, EmpDate
  from C.Emptable
  where EmpDate &gt; '2015-01-01'
  </code></pre>
  
  <p>VS. </p>
  
  <p>Creating a .net Method GetEmpData to call each query and combine their results as:</p>
  
  <pre><code>var response = await Task.WhenAll(GetEmpData(A,'2015-01-01'),GetEmpData(B,'2015-01-01'),GetEmpData(C,'2015-01-01'));
  var result = response[0].Concat(response[1]).Concat(response[2]).ToList();
  </code></pre>
  
  <p>Thanks.</p>