更好地遵循数据库的方法 [英] Better approach to follow in database

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

问题描述

我有几个记录保存到数据库中,每个大约12 KB。它们以10到15个记录的形式出现。我可以选择2种方法。



1.在C#中迭代记录并逐个发送到数据库进行保存。 (每次10到15个DB 12 KB的请求)。

2.在DB中一次推送所有记录,让存储过程执行迭代作业并保存每条记录。 (只有一个请求数据库120KB到180KB)。



这将用于配置为每天午夜运行的作业。请建议哪种方法更好,为什么?



我尝试过:



我已准备好两个代码,只有方法才能确定。

I have few records to save into database, approx 12 KB each. They are coming as bunch of 10 to 15 Records. I have option of 2 approaches to follow.

1. Iterating Records in C# and sending them one by one to Database to save. (10 to 15 requests to DB 12 KB each).
2. Pushing all records at once in DB, and let the stored procedure do the Jobs of Iterating and saving each record. (Only one request to DB 120KB to 180KB).

This is gonna be used in a job which is configured to run everyday midnight. Please suggest which is approach is better and why?

What I have tried:

I have both code ready, only approach is to be decided.

推荐答案

哪个更好,为什么? - 在我们回答之前我们还没有很多信息 - 无论是哪种情况/'方法',您是否考虑过交易/范围,恢复(即如果插入不可能发生什么),原始交易是否存储在某处(备份),您有什么审计程序 - 例如(可能)每日报告已输入数据库的内容和/或警报是否存在任何类型的错误,例如无法连接到数据库并且事务可以在以后获取?



数据的上下文是什么?是否必须插入所有记录才能完成运行/批处理?或者1个插入失败的情况1使整个过程无效???



'即将'你说?从哪里/什么??源系统是否备份数据???



对不起,我是一个挑剔的老屁,但是你不知道你的数据在哪里/它处于什么状态你遇到了麻烦 - 方法1或2可能没有任何不同的时间,但我只会回答围绕'数据完整性/安全性'等问题而且对于看似少量的数据它们可能更重要。



最后一个问题...当你的老板来找你并说你从一夜10-15条记录到10,000-15,000条记录时会发生什么?那你会做什么??
"Which is better and why ?" - there's a lot of information we dont have before we could answer that - in either case/'approach', have you thought about transactions/scope, recovery (ie what happens if the insert cant happen), do the raw transactions get stored somewhere (backup), what audit procedures do you have - eg (maybe) a daily report of what has been entered into the database and/or an alert if there's any sort of error eg cant connect to database and the transactions can be picked up later ?

What is the context of the data ? do all the records have to be inserted for the run/batch to be complete ?? or does failure of 1 insert in case 1 invalidate the entire process ???

'coming' you say ? from where/what ?? does the source system back up the data ???

Sorry, Im a picky old fart, but the minute you dont know where your data is/what state its in, you're in trouble - approach 1 or 2 may not be any different timewise, but I would have though only you can answer the questions around 'data integrity/safety' etc and they are likely more important for a seemingly small amount of data.

Last question ... what happens when your boss comes to you and says you're going from 10-15 records a night to 10,000-15,000 records ? what will you do then ??


这篇关于更好地遵循数据库的方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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