.net / Sql服务器中的数学运算 [英] Math Operations in .net / Sql server

查看:78
本文介绍了.net / Sql服务器中的数学运算的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我需要在应用程序中执行一些数学运算。我想要建议在哪个部分实现性能更高效。



就像我需要从db中的4个表中获取数据。然后在检索到的数据,数字,乘法&分区将发生。



我的问题是在存储过程中实现这些计算,或者在网格视图行绑定事件中的代码中实现。哪个会有更好的表现?



Ex。 db中的计算:

SELECT CAST(ROUND((

((CAST(25为浮动)/ CAST(100为浮动))* CAST(87.25 AS FLOAT))

((CAST(25浮动)/ CAST(100浮动))* CAST(68.04 AS FLOAT))

( (CAST(25为浮动)/ CAST(100为浮动))* CAST(70.37 AS FLOAT))

((CAST(25为浮动)/ CAST(100为浮动))* CAST (72.00 AS FLOAT))

),2)AS NUMERIC(8,2))




如果数据库怎么办?有更多的数据。我需要在db中使用while循环进行计算。这对性能是否合适。

Hi All,

I need to perform some mathematical operations in an application. i want suggestions that implementing at which part will be performance wise more productive.

Like i need get data from 4 tables in db. And after that on retrieved data, numeric, multiplications & divisions will take place.

My questions is implementing these calculations in a stored procedure, or in code behind in grid view row bound event. Which will have more performance?

Ex. calculation in db:
SELECT CAST(ROUND((
((CAST(25 as float)/ CAST(100 as float)) * CAST(87.25 AS FLOAT)) +
((CAST(25 as float)/ CAST(100 as float)) * CAST(68.04 AS FLOAT)) +
((CAST(25 as float)/ CAST(100 as float)) * CAST(70.37 AS FLOAT)) +
((CAST(25 as float)/ CAST(100 as float)) * CAST(72.00 AS FLOAT))
), 2) AS NUMERIC(8,2))


What if the db has lot more data. And i need to use while loop in db for the calculations. Is that okay for performance wise.

推荐答案

存储过程只会有更好的性能。它是一个预编译的代码..

如果你想知道准确的结果,请查看分析器。
stored procedures only will have better performance. its a precompiled code..
if you want to know the accurate results, pls check with profiler.


这篇关于.net / Sql服务器中的数学运算的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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