如何在最短的时间内将大数据存储在数据表中? [英] How to store large data in datatable in minimum time ?

查看:90
本文介绍了如何在最短的时间内将大数据存储在数据表中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好先生,



我尝试将大量(超过2个Lac)数据加载到DataTable中,但需要超过40分钟。将数据加载到数据表中。



我需要在最短的时间内加载这些数据。



请帮忙!!



谢谢



我尝试了什么:



 使用(OracleConnection con =  new  OracleConnection(conn))
{
string Query = 选择* FROM TABLE;

使用(OracleCommand cmd = new OracleCommand(Query,con))
{
con.Open();
cmd.CommandTimeout = 120000 ;

使用(OracleDataReader odr = cmd.ExecuteReader())
{
dt.Load(odr);
}
}

con.Close();
}

解决方案

首先查看您要加载的数据量,以及是否需要全部数据。这是很多行,所以它需要一些时间,但除非你的带宽确实非常低,或者你的服务器非常慢,40分钟意味着你正在加载一些巨大的数据列 - 原因可能是<$你正在使用c $ c> SELECT * FROM 。只能获取您实际需要的列 - 如果您要加载大图像或视频,那么这将花费大量时间。所以尝试用一个简单列的名称替换星号,看看它需要多长时间。

然后看看你为什么一次加载这么多行:如果要显示它们对用户来说,这是一个非常糟糕的主意,而不仅仅是来自性能POV!


添加到 OriginalGriff 所说的,如果你想要显示大某些网格/表格格式的数字记录,始终使用自定义分页概念。



这将帮助您仅获取所请求页面的记录并直接在UI上显示。

Hello Sir,

I'm try to load large(more than 2 Lac) data into DataTable but it take more than 40 min. to load the data into datatable.

I need to load that data within a minimum time .

Pls Help !!

Thanks

What I have tried:

using (OracleConnection con = new OracleConnection(conn))
{
    string Query = "Select * FROM TABLE" ;

    using (OracleCommand cmd = new OracleCommand(Query, con))
    { 
        con.Open();
        cmd.CommandTimeout = 120000;
        
        using (OracleDataReader odr = cmd.ExecuteReader())
        {
            dt.Load(odr);
        }
    }

    con.Close();
}

解决方案

Start by looking at how much data you are loading, and if you need it all. That's a lot of rows, so it will take some time, but unless your bandwidth is really, really low, or your servers are spectacularly slow, 40 minutes implies that you are loading some HUGE data columns - and the reason is probably the SELECT * FROM you are using. Only ever fetch the columns you actually need - if you are loading big images, or videos, then that will take major amounts of time. So try replacing the star with just the name of a single simple column, and see how long it takes for that.
Then look at why you are loading so many rows at once: if it's to display them all to the user, then that's a very bad idea, and not just from a performance POV!


Adding to what OriginalGriff said, if you want to show large number records in some grid/table format, always use custom paging concept.

That will help you to get only records of the page requested and show it directly on UI.


这篇关于如何在最短的时间内将大数据存储在数据表中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆