访问数据库中的大数据 [英] Accessing Large data in database

查看:109
本文介绍了访问数据库中的大数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我在数据库名称Tab1&中有2个表。 Tab2。

Tab1由以下列组成。

Col1,Col2,Col3,Col4,.....



Tab2由以下列组成。

Col2,Col5,Col6,Col7,.....



和一个名为的数据表tempTab。

tempTab由以下列组成。

Col1,Col4,Col6,Col7



有大的Tab1和Tab2中的数据量(每个700万),tempTab包含少量数据(比如500)。现在我要检查Tab1&中存在来自tempTab的行。 TAB2。我做的是我迭代tempTab(在for循环中)并每次运行查询创建与数据库的连接(

Hi,

I''ve 2 tables in database name Tab1 & Tab2.
Tab1 consists of following columns.
Col1,Col2,Col3,Col4,.....

Tab2 consists of following columns.
Col2,Col5,Col6,Col7,.....

and a datatable named tempTab.
tempTab consists of following columns.
Col1,Col4,Col6,Col7

There are large amount of data(7 million each) in Tab1 and Tab2, and tempTab consists of few data(say 500). Now i''ve to check which rows from tempTab exist in Tab1 & Tab2. what I did is that I iterate tempTab(within a for loop) and create connection with Database every time to run a query (

select t1.Col1,t1.Col4,t2.Col7 from Tab1 t1 join Tab2 t2 on t1.Col2=t2.Col2 where t1.Col1='tempTab.Col1' and t1.Col4='tempTab.Col4' and t2.Col6='tempTab.Col6' and t2.Col7='tempTab.Col7'

)。因此,我必须在该循环(for循环)中对数据库进行500次迭代以进行迭代。我想,这是不好的做法。花了更多的时间。



有没有解决方案???

请尽快帮助。

提前致谢。

). Thus i''ve to hit Database 500 times within that loop(for loop) for iterating. I think, this is bad practice. It took more time also.

Is there any solutions for this ???
Please help as soon as possible.
Thanks in advance.

推荐答案

尝试这样的事情:

Try something like this:
select t1.Col1,t1.Col4,t2.Col7 
from Tab1 t1 
join Tab2 t2 on t1.Col2=t2.Col2 
INNER JOIN tempTab ON t1.Col1 = tempTab.Col1 
    and t1.Col4 = tempTab.Col4 
    and t2.Col6 = tempTab.Col6 
    and t2.Col7 = tempTab.Col7 


在DB上创建一个表来表示tmptable(如果你需要多个流程让审查添加adictional colum n用于存储与进程唯一的sessionid)用于与其他表进行make连接,使用批量插入并调用SP进行查看以及删除tmptable数据之后。您可以使用和xml传递行,但必须在C#上进行序列化并在TSQL上反序列化,对于大型xml,它具有较低的性能
Create a table on DB for represent the tmptable( if you need to multiple process make review add adictional column for store a sessionid unique for process) for make joins with other table, use a bulk insert and call a SP for make the review and after it delete tmptable data. You can use and xml to pass the rows but have to serialize on C# and deserialize on TSQL, in this last for large xml it have a low performace


这篇关于访问数据库中的大数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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