从内存中的DB加载数据的最佳方法(如果需要) [英] Best approach to load data from DB in memory (if needed)

查看:114
本文介绍了从内存中的DB加载数据的最佳方法(如果需要)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在计划一个项目,处理多个公司和用户的各种税收。我将使用C#(winforms),分层架构(UI,DAL,BLL和WebService)和SQL Server。



应用程序将被多个用户使用,其中一个用户将同时处理数百(最多数千)个记录,这些记录必须加载,更新和设置。



我希望你的帮助决定是否我必须在程序启动时将数据加载到对象中,或者根据需要加载数据。我不知道如何决定这个,如果数据应该预先加载,这是最好的使用方法,因为数据必须保存回数据库。



我知道我还没有任何代码可以在这里发帖,请原谅我,但我还处于计划阶段,所以我要问一个理论问题。

I am planning for a project that deals with all kinds of tax for multiple companies and users. I'll be using C# (winforms), layered architecture (UI, DAL, BLL and WebService) and SQL Server.

Application will be used by multiple users, where a single user will deal with hundreds (maximum thousands) records at a time, which will have to be loaded, updated and set.

I want your help in deciding if I have to load my data into objects on program's start-up or something, or go with loading data on demand. I'm not sure how to decide this, and in case data should be pre-loaded which is the best approach to use since data will have to be saved back to DB.

I know I don't have any code to post here yet, forgive me but I'm still in the planning phase so I'm asking a theoretical question.

推荐答案

您几乎没有提供有关如何使用您的应用程序的信息 - 这是您在此要求做出此决定的关键......

无论如何我不建议预先加载数据。如果你有庞大的数据,它将需要巨大的内存来容纳它,这应该是一种浪费。如果您的数据很小,那么仅按需加载它们不会是性能问题...

您可能会考虑使用SQL缓存来提高性能,但是在一个简单的CRUD应用程序中移动一个只需一步就可以获得数千条记录,只需设计精良的DAL ...
You gave almost no information on how your application will be used - and that's the key for such a decision you ask for here...
In any case I would not advise to pre-load data. If you have huge data it will demand huge memory to contain it, and that should be a waste. If your data is small it will not be a performance issue to load them on demand only...
What you may consider is using SQL caching to improve performance, however in a simple CRUD application that move a few thousands of records maximum in one step you will need nothing, only well designed DAL...


我同意Kornfeld Eliyahu Peter - 不要预加载,根据需要加载数据它。



如果用户在税务系统中一次处理数百条记录,我会有点担心但我认为这只是我误解了你的要求。然而,听起来你肯定需要考虑交易处理......例如请参阅此CP文章 SQL Server事务和错误处理 [ ^ ]
I agree with Kornfeld Eliyahu Peter - don't pre-load, load data as you need it.

I'd be a little concerned if a user was dealing with hundreds of records "at a time" in a tax system but I think that is just me misunderstanding your requirements. However it sounds like you will definitely need to consider transactional processing ... e.g. see this CP article SQL Server Transactions and Error Handling[^]


这篇关于从内存中的DB加载数据的最佳方法(如果需要)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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