插入大量记录 [英] inserting large volume of records

查看:82
本文介绍了插入大量记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我有一种将批量记录插入sqlserver表的方案.
在这里,我正在根据某种条件验证每个记录列的值.

所以我有一个临时表,验证后我将从该表的每条记录移到原始表.

我的问题是,
当我第一次插入记录时,它的加载速度非常快.100000条记录大约需要3-5分钟.如果我插入200000,则需要10分钟.但是当我下次尝试插入时,即下次插入1000条记录时间(指一两个小时后)变得非常缓慢.

如果我截断了原始表中的所有值并再次启动了该过程,则其加载速度非常快.

为什么会这样?

有人能说出原因吗?
同时也帮助我解决了这个问题.
请.....

Hi,
I have a scenario that inserting bulk records into sqlserver table.
Here i am validating each record-column value based on some condition.

So i have one temporary table, from that table each and every record i am moving to original table after validation.

My problem is,
when the first time i am inserting records it is ge tting loaded veryfast.It takes around 3-5 mins for 100000 records.if i insert 200000 then 10 mins .But when i am trying to insert next time ie,1000 records for the next time(means after an hour or two)it is getting very slow.

If i truncate all values from original table and started the process again ,then its loading very fast.

Why this happens?

Can anybody tell the reason?
And also help me to solve this issue.
please.....

推荐答案

您的数据库越来越慢,因为它必须插入更多条目.我猜想原因与您在表上设置的索引有关.它有聚簇索引吗?这样可以加快查找速度,但是随着表大小的增加,插入操作也会变慢.
Your database gets slower as it has to insert more entries. I''d guess the reason has to do with indexes you have set up on the table. Does it have a clustered index ? That makes lookups fast, but inserts get slower as the table size grows.


这篇关于插入大量记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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