3

Among TSQL types (MSSQL): real, float and decimal; which type would result in faster comparisons?

Would decimal use hardaware FPU computation or is it purely in software?

Bill the Lizard
  • 398,270
  • 210
  • 566
  • 880
loopedcode
  • 4,863
  • 1
  • 21
  • 21
  • In most cases, SQLServer instances are not very demanding on CPU; its bottlenecks are usually related to IO and network subsystems. Thus, this kind of micro-optimization should only be thought of if a real problem is detected on a running system. – Gerardo Lima May 22 '12 at 13:03

2 Answers2

1

Decimals cannot use the FPU. You get best performance with float or real which map to a standard IEEE floating point number which is supported by the FPU.

float = double real = single

Of course, single is faster.

usr
  • 168,620
  • 35
  • 240
  • 369
0

Are these relative comparisons >, < or equality comparisons =, != ?

Floats and reals are approximation data types where as a decimal is an actual representation. If you're doing equality, you'll want to stay away from floats and reals. So that leaves decimals.

More than likely, SQL Server won't go to the FPU for relative comparisons. FPU and other coprocessors are used for arithmetic.

Michael Rice
  • 1,173
  • 5
  • 13