简体   繁体   English

从SQL Server处理大量数据

[英]Processing huge data from sql server

I have a stored procedure (SQL Server 2016) which currently returns 100K to 200K rows based on the parameters to that SP. 我有一个存储过程(SQL Server 2016),当前基于该SP的参数返回100K至200K行。

Each row can be a size of 100KB to 200KB. 每行的大小可以为100KB至200KB。 So total size can be around 10GB to 20GB. 因此,总大小约为10GB至20GB。

My client(background job) has to call this SP and process all rows and send it to another client. 我的客户端(后台作业)必须调用此SP并处理所有行并将其发送给另一个客户端。

What is the best approach to handle such scenarios? 处理此类情况的最佳方法是什么?

Currently I am thinking of using streaming enumerator using yield. 目前,我正在考虑使用使用yield的流式枚举器。

Get the record whenever the 'datareader.Read()' read a row and process it and send it to other client. 每当“ datareader.Read()”读取一行并对其进行处理并将其发送给其他客户端时,获取记录。

dataReader = command.ExecuteReader();                    
while (dataReader.Read())
{
    obj = new SomeClass();

    // prepare Someclass

    yield return obj;
}

Is this approach sufficient to handler such large data? 这种方法足以处理如此大的数据吗?

Is there any better approach to it? 有什么更好的方法吗? (Such as multi threading etc.) (例如多线程等)

If so how should I approach to it. 如果是这样,我应该如何处理。 Any pointers to refer? 有指针要参考吗?

Edit: SP has multiple joins and runs couple of times in a day. 编辑:SP有多个联接,并且一天运行两次。

根据您的描述,我认为这是实施SSIS(集成服务)的好方案,该SSIS可以管理最终结果并将其写入CSV文件,并允许客户交换。

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

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