Unix Technical Forum

Re: Database design/optimization question

This is a discussion on Re: Database design/optimization question within the SQL Server forums, part of the Microsoft SQL Server category; --> Quick question - since the values will all be from 1-100, is there any performance advantage to using tinyint ...


Go Back   Unix Technical Forum > Database Server Software > Microsoft SQL Server > SQL Server

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-28-2008, 04:56 PM
Mike Thompson
 
Posts: n/a
Default Re: Database design/optimization question

Quick question - since the values will all be from 1-100, is there any
performance advantage to using tinyint instead of int?

Thanks.

Mike
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-28-2008, 04:57 PM
Erland Sommarskog
 
Posts: n/a
Default Re: Database design/optimization question

Mike Thompson (begeneric@hotmail.com) writes:
> Quick question - since the values will all be from 1-100, is there any
> performance advantage to using tinyint instead of int?


Yes, there is. To wit, int takes up four bytes and tinyint takes up one
byte. That means that which ever model you go with, you can have more
rows per page, and that means that SQL Server has do to less amount of
disk access, which is a very significant factor in the execution-time
equation.


--
Erland Sommarskog, SQL Server MVP, sommar@algonet.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-28-2008, 04:57 PM
Erland Sommarskog
 
Posts: n/a
Default Re: Database design/optimization question

Mike Thompson (begeneric@hotmail.com) writes:
> Quick question - since the values will all be from 1-100, is there any
> performance advantage to using tinyint instead of int?


A caveat. Consider this script:

declare @x tinyint, @y tinyint
select @x = 9, @y = 18
select @x - @y

This script fails with

Server: Msg 8115, Level 16, State 2, Line 3
Arithmetic overflow error converting expression to data type tinyint.

because tinyint does not include negative values.

In your query you have the expression val1 - accuracy, so this could
happen to you, both the value and the accuracy are tinyint.

--
Erland Sommarskog, SQL Server MVP, sommar@algonet.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 02-28-2008, 05:00 PM
AMIT
 
Posts: n/a
Default Re: Database design/optimization question

Hi,

Refer this link for optimization and database design issue and solution.

www.sql-server-performance.com

Thanks , Amit



begeneric@hotmail.com (Mike Thompson) wrote in message news:<91e39a0b.0306251156.37e5bc48@posting.google. com>...
> Quick question - since the values will all be from 1-100, is there any
> performance advantage to using tinyint instead of int?
>
> Thanks.
>
> Mike

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 08:21 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com