简体   繁体   English

比较两个大型列表的最佳方法,C#

[英]Best way to compare two large list, C#

This is for one of my ETL project to sync two database, some table is 4G, so ETL job just load updated data to insert or update, that works fine, but the source table will delete some records, and I want to delete from my table too. 这是我的ETL项目之一,用于同步两个数据库,某些表是4G,所以ETL作业只是加载更新的数据以进行插入或更新,效果很好,但是源表将删除一些记录,并且我想从我的表中删除表也​​。 What I did is: 我所做的是:

List<long> SourceIDList; // load all ID from source table
List<long> MyIDList; // load all ID from my table
var NeedRemoveIDList = MyIDList.Except( SourceIDList );
foreach(var ID in NeedRemoveIDList)
   // remove from my table

The code logic work, but load ID from 4G table to List will through "out of memory" exception, is there better way? 代码逻辑可以工作,但是将ID从4G表加载到List将通过“内存不足”异常,是否有更好的方法?

感谢所有注释,最终我在数据库中执行了此操作,在临时表中插入了两个列表,并使用SQL进行比较,花了一些时间来插入数据,但是由于这是ETL作业,因此只需几分钟就可以了。

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

相关问题 在C#中比较复杂对象的两个列表的最佳方法是什么 - What is the best way to compare two list of complex object in c# 使用C#和LINQ比较两个大型字符串列表的最佳方法是什么? - Best way to compare two large string lists, using C# and LINQ? 比较 c# 中两个对象的最佳方法是什么 - What is the best way to compare two objects in c# C#最好的方式来比较一天中的两个时间 - C# best way to compare two time of the day 在C#DataGridView中填充大文件列表的最佳方法 - Best way to populate large file list in c# DataGridView 比较C#上的两个List &lt;&gt; - Compare two List<> on C# C#比较类字段的最佳方法 - C# Best way to compare fields of class 在 c# 中将 100 万个对象列表与另一个 100 万个对象列表进行比较的最佳方法 - Best Way to compare 1 million List of object with another 1 million List of object in c# C#比较双精度值和一系列值并返回两个文本值的最佳方法是什么 - C# What is the best way to compare a double value to a range of values and return two text values 在 C# 中比较两个 DateTime 的相等性的最佳方法是什么……但只能达到一定的精度? - What's the best way to compare the equality of two DateTime's in C#… but only to a certain precision?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM