用C#或存储过程进行计算? [英] Do calculations in C# or Stored Procedure?

查看:64
本文介绍了用C#或存储过程进行计算?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我有一个包含大量财务数据的数据库。我想

检索一些数据,用它运行som计算,没什么复杂的只需

简单算术。


我想知道是否让存储过程执行此操作更快或者更好(更快)只需在简单的SELECT语句中检索数据

并让应用程序执行此操作计算?


问候

Fredrik

解决方案

Frederik,


这取决于您希望客户获得什么结果。它是一个值,比我使用SP的价值多少b $ b。但是,如果您需要基础数据,那么
当然比客户端的C#程序。


请注意,存储过程几乎永远存在在Microsoft数据库上首先编译
,因此将永远比你的C#解决方案慢得多。


我希望这会有所帮助,


Cor

< fr ********** @ gmail.com> schreef in bericht

news:11 ********************** @ e56g2000cwe.googlegr oups.com ...



我有一个包含大量财务数据的数据库。我想要检索一些数据,用它运行som计算,没有什么复杂的简单算法。

我想知道让存储过程做的更快这个或更好(更快)只需在一个简单的SELECT语句中检索数据
并让应用程序进行计算?

问候
Fredrik


Vadym,


如果您需要在客户端打印100K行,而不是我的想法

我会在客户端进行计算。


我在C#中编写计算的优势要快得多,而且

客户端是很少是一台性能远低于服务器的计算机。通常

客户端计算机有更快的处理器。


和我写的一样,如果只需要得到的结果值比你我b / b $ b会在服务器上执行此操作。


但这不是一个简单的答案,因为它更快使用

存储程序,这取决于您使用数据的方式。


Cor

" Vadym Stetsyak" < VA ***** @ ukr.net> schreef in bericht

新闻:%2 **************** @ TK2MSFTNGP03.phx.gbl ...

您好, Cor!

CLM>这取决于您希望客户获得什么结果。它是一个
CLM>价值,比我使用SP。但是,如果您还需要
CLM>基础数据,当然还有客户端的C#程序。

然后,你说,如果我们有100K行并希望得到它们的一些子集(执行连接)和计算我们编写客户端应用程序的一些值?

这取决于操作类型。我很难想象在客户端实现连接
或聚合函数。数据库服务器就是为此而设计的。

CLM>请注意,存储过程几乎永远存在于Microsoft
CLM>数据库首先要编译,所以将永远慢于
CLM>你的C#解决方案。

这取决于它的编写方式。前一段时间我们得到的SP需要2个小时才能完成。经过多次优化(删除游标等),
存储过程在大约1-2分钟内完成,数据量相同。

客户希望程序使用计算结果或数据操作而不执行它们。

-
问候,Vadym Stetsyak
www: http://vadmyst.blogspot.com





问题是:你想用

计算加载你的数据库服务器吗?


或者你想让它专注于提供数据并在中间件或客户端上执行这些计算。

fr ********** @ gmail.com 写道:



我有一个包含很多的数据库财务数据。我想要检索一些数据,用它运行som计算,没有什么复杂的简单算法。

我想知道让存储过程做的更快这个或更好(更快)只需在一个简单的SELECT语句中检索数据
并让应用程序进行计算?

问候
Fredrik


Hi,

I have a database which contains alot of finacial data. I want to
retreive some data, run som calculations with it, nothing complex just
simple arithmetic.

I wonder if it''s faster to let a stored procedure to do this or is
better (faster) to just retrive the data in a simple SELECT statement
and let the application do the calculation?

Regards
Fredrik

解决方案

Frederik,

It depends what result you want to be get by the client. Is it one value,
than I would use the SP. However if you need as well the underlying data,
than of course the C# program on the client side.

Be aware that a stored procedure has almost forever on Microsoft database to
be compiled first, so will be forever much slower than your C# solution.

I hope this helps,

Cor
<fr**********@gmail.com> schreef in bericht
news:11**********************@e56g2000cwe.googlegr oups.com...

Hi,

I have a database which contains alot of finacial data. I want to
retreive some data, run som calculations with it, nothing complex just
simple arithmetic.

I wonder if it''s faster to let a stored procedure to do this or is
better (faster) to just retrive the data in a simple SELECT statement
and let the application do the calculation?

Regards
Fredrik



Vadym,

If you need 100K rows which should be printed on the Client, than in my idea
I would do the calculations on the Client.

Advantage as I wrote the calculation in C# is much quicker plus that the
client is seldom a computer with much less performance than a server. Often
the client computers have quicker processors.

The same as I wrote that if only the resulting value is needed than you I
would do it on the Server.

But this is not to be given in a simple answer as, "it is quicker using a
Stored Procedure", that is depending on the way you use the data.

Cor
"Vadym Stetsyak" <va*****@ukr.net> schreef in bericht
news:%2****************@TK2MSFTNGP03.phx.gbl...

Hello, Cor!

CLM> It depends what result you want to be get by the client. Is it one
CLM> value, than I would use the SP. However if you need as well the
CLM> underlying data, than of course the C# program on the client side.

Then, you say, that if we have 100K rows and want to get some subset of
them ( perform join ) and calculate some values we write client side app?

It depends, on type of operations. I can hardly imagine implementing joins
or aggregate functions on client side. DB server was designed to do that.

CLM> Be aware that a stored procedure has almost forever on Microsoft
CLM> database to be compiled first, so will be forever much slower than
CLM> your C# solution.

It depends on how it is written. Some time ago we got SP that took 2 hours
to complete. After number of optimizations ( removal of cursors and etc ),
stored procedure was completing in about 1-2 minutes with the same amount
of data.

It is desirable that client program use results of computations or data
manipulations and not perform them.

--
Regards, Vadym Stetsyak
www: http://vadmyst.blogspot.com




The question is: Do you want to load your database server with
calculations?

Or do you want it to focus on serving up data and perform those
calculations on the middleware or client.

fr**********@gmail.com wrote:

Hi,

I have a database which contains alot of finacial data. I want to
retreive some data, run som calculations with it, nothing complex just
simple arithmetic.

I wonder if it''s faster to let a stored procedure to do this or is
better (faster) to just retrive the data in a simple SELECT statement
and let the application do the calculation?

Regards
Fredrik



这篇关于用C#或存储过程进行计算?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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