简体   繁体   English

在32位Windows XP下的C#4 / T-SQL2008应用程序中使用Int64 / bigint而不是Int32 / int会有多大的性能损失?

[英]How significant is a performance penalty for using Int64/bigint instead of Int32/int in a C#4/T-SQL2008 application under 32-bit Windows XP?

For a scientific project of mine I am developing (in C#4 and T-SQL) an application potentially meant to handle very big quantities of very simple records performing simple operations with them (a scientific simulation engine, not a linear time-series cruncher). 对于我的一个科学项目,我正在开发(在C#4和T-SQL中)一个应用程序可能意味着处理非常大量非常简单的记录,用它们执行简单的操作(科学模拟引擎,而不是线性时间序列计算器) )。 I'd like to use 64-bit integers as primary keys for better capacity. 我想使用64位整数作为主键以获得更好的容量。

I am going to integrate using of Entity Framework, POCO collections and arrays processing and T-SQL stored procedures practically. 我将实际集成使用Entity Framework,POCO集合和数组处理以及T-SQL存储过程。

I am going to store a database on an SQL Server 2008 and access it from multiple application instances simultaneously for distributed processing. 我将在SQL Server 2008上存储数据库,并同时从多个应用程序实例访问它以进行分布式处理。

SQL Server and application instances are going to be run on 32-bit Windows XP systems, sometimes on completely 64-bit-unaware hardware. SQL Server和应用程序实例将在32位Windows XP系统上运行,有时在完全64位无意识的硬件上运行。

What penalties am I going to face for using 64-bit integer types as primary keys? 使用64位整数类型作为主键我将面临什么惩罚?

As long as you stick to reading and writing those numbers (ie no arithmetic, just database queries), the performance hit will be negligible. 只要你坚持阅读和编写这些数字(即没有算术,只是数据库查询),性能损失将是微不足道的。 It will be like using 2 int s as parameters instead of 1. 这就像使用2 int作为参数而不是1。

Once you start doing arithmetic on them however, it starts to get messy. 然而,一旦你开始对它们进行算术运算,就会开始变得混乱。 Addition and subtraction is roughly 3 times as slow as for normal int s. 相加和相减是作为正常大致3倍慢int秒。 Multiplication and division is a LOT slower, over an order of magnitude. 乘法和除法比较慢,超过一个数量级。 I posted the code for multiplying 2 64-bit numbers on a 32-bit cpu somewhere on this site, I could look it up if you want, but it's over 3 pages long. 我在这个网站的某个地方发布了在32位cpu上乘以2个64位数字的代码,如果你愿意,我可以查找它,但它超过3页。

Seeing how you're talking about ID fields however, you shouldn't be doing any arithmetic on them right? 看到你如何谈论ID字段,你不应该对它们进行任何算术吗? So you should be fine. 所以你应该没事。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM