Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
DB Engine
SQL ServerMSDESQL Server CE
Services
Analysis (Data Mining)Analysis (OLAP)DTSIntegration ServicesNotification ServicesReporting Services
Programming
CLRConnectivitySQLXML
Other Technologies
ClusteringEnglish QueryFull-Text SearchReplicationService Broker
General
Data WarehousingPerformanceSecuritySetupSQL Server ToolsOther SQL Server Topics
DirectoryUser Groups
Related Topics
MS AccessOther DB ProductsMS Server Products.NET DevelopmentVB DevelopmentJava DevelopmentMore Topics ...

SQL Server Forum / General / Data Warehousing / September 2005

Tip: Looking for answers? Try searching our database.

int Versus decimal

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Herb Ray - 15 Sep 2005 15:30 GMT
Howdy - -

    I have to keep time series on large amounts of numeric data (millions
of rows).  I had the idea of storing these data as int and converting to
decimal in views; this way, my numeric columns shrink down to four bytes
from 9 bytes.

    Would the performance gained be an improvement even with the conversion
overhead of the view?

- - Herb
Adam Machanic - 15 Sep 2005 17:31 GMT
INT only uses 4 bytes because it doesn't have the precision that DECIMAL
has.  How are you hoping to maintain the same precision when converting back
and forth?

By the way, if your column uses a precision up to 9 digits (decimal), it
will only use 5 bytes.

Signature

Adam Machanic
SQL Server MVP
http://www.datamanipulation.net
--

> Howdy - -
>
[quoted text clipped - 7 lines]
>
> - - Herb
Herb Ray - 15 Sep 2005 17:44 GMT
> INT only uses 4 bytes because it doesn't have the precision that DECIMAL
> has.  How are you hoping to maintain the same precision when converting back
> and forth?
>
> By the way, if your column uses a precision up to 9 digits (decimal), it
> will only use 5 bytes.

Adam - -

    Actuall, you're right.  But, I do have data where smallint gives me
sufficient precision, so I would be storing two bytes instead of five
bytes for decimal.  Is it worth it to convert in the view?

- - Herb
Adam Machanic - 15 Sep 2005 18:12 GMT
> Actuall, you're right.  But, I do have data where smallint gives me
> sufficient precision, so I would be storing two bytes instead of five
> bytes for decimal.  Is it worth it to convert in the view?

   You'd have to test on your end, with your data, to make that
determination.  But my gut instinct would be probably not.  That's a pretty
small difference in size, and although it might add up substantially over
billions of rows and give an I/O benefit in that case, I don't think it
would work in the millions (you're talking about a only few megs difference
on that scale.)  There is also the overhead of the type conversion, which
may be expensive over so many rows -- but as to whether it would defeat the
possible I/O benefit, I cannot say; I think it would depend on many factors,
including how CPU-bound your servers are, and how fast your disks are.

Signature

Adam Machanic
SQL Server MVP
http://www.datamanipulation.net
--

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.