简体   繁体   English

DB2 Union all vs并行运行

[英]DB2 Union all vs Parallel run

We have separate Databases in DB2 for each customer but with same table structure in each of them. 在DB2中,每个客户都有单独的数据库,但是每个客户都有相同的表结构。 For a .Net Application I need to scan all the databases and show result for the matching entries to the user. 对于.Net应用程序,我需要扫描所有数据库并向用户显示匹配条目的结果。 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. 我想知道对所有数据库执行UNION ALL或并行运行每个查询,然后从我的.Net应用程序中合并它们会更快。

Select EmpName, EmpSal, EmpDate
from A.Emptable
where EmpDate > '2015-01-01'
UNION ALL
Select EmpName, EmpSal, EmpDate
from B.Emptable
where EmpDate > '2015-01-01'
UNION ALL 
Select EmpName, EmpSal, EmpDate
from C.Emptable
where EmpDate > '2015-01-01'

VS. VS.

Creating a .net Method GetEmpData to call each query and combine their results as: 创建一个.net方法GetEmpData来调用每个查询并将其结果组合为:

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();

Thanks. 谢谢。

If your federation is optimally configured for all aspects (especially pushdown and performance aspects), then I expect the UNION ALL to be more maintainable in the long term. 如果针对所有方面(尤其是下推和性能方面)都对联盟进行了最佳配置,那么我希望UNION ALL从长远来看将更具可维护性。 As regards relative performance, you can measure, because so many factors influence that. 关于相对性能,您可以衡量,因为有很多因素会影响它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM