all groups > sql server programming > july 2006 >
You're in the

sql server programming

group:

Size of column of datatype Image


Size of column of datatype Image Jonas Mandahl Pedersen
7/22/2006 8:36:36 PM
sql server programming:
Dear NG

I have a table in my database where I store key / value pairs for a dynamic
form designer.
It has the definition:

ID INT,
DATATYPE TINYINT,
VALUE Varchar(250)

( I asume each row takes 4+1+length(value) bytes?
All conversion is done in the client application and the datatype is set
according to the datatype of the value.
All this work fine.

Now one of my customers also would like to add dynamic pictures to their
forms.

So a simple solution is to change the structure to:

ID INT,
DATATYPE TINYINT,
VALUE IMAGE

How much will each record take for the new structure?

Sample of the data:

ID DATATYPE VALUE
---- - ------------------------
1 2 15-02-1987 14:03:05
2 1 This is test data only
3 3 1544

BR Jonas

Re: Size of column of datatype Image Erland Sommarskog
7/22/2006 10:30:13 PM
Jonas Mandahl Pedersen (jonas@jmp.dk) writes:
[quoted text, click to view]

+ two bytes for the length of the varchar. Plus some overhead bytes.

[quoted text, click to view]

If you don't set the option "text in row", there are 16 bits in the
row for a pointer to where the image data resides. The image takes
up as many page as needed, so there is a minimum of 8000 bytes.




--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
Re: Size of column of datatype Image Jonas Mandahl Pedersen
7/23/2006 12:00:00 AM
Will this mean that the new structure will take 16(pointer to where the
image data resides) - 2 (length of varchar) = 14 bytes more than the old
structure?

Do you think there iwll be any performance difference?

Thanks
Jonas

[quoted text, click to view]

Re: Size of column of datatype Image Kalen Delaney
7/23/2006 9:08:51 AM
The pointer to the IMAGE data is 16 bytes, not 16 bits.
There is not always a minimum of 8000 bytes per row. Smaller amounts of data
can share the same pages, so you could have 5 rows, each with IMAGE data,
and they only need one or two extra pages.

--
HTH
Kalen Delaney, SQL Server MVP


[quoted text, click to view]

Re: Size of column of datatype Image Kalen Delaney
7/23/2006 9:17:53 AM
Hi Jonas

If you're actually calculating space used down to the byte, you also need to
take into account that there are additional overhead bytes on each row.

The text/image pointer is considered a variable length column, so you do not
lose the 2 bytes.

There is always a performance difference when you have to access additional
pages beside the regular table data. If you have to do multiple reads of
IMAGE pages for each row of data, the extra reads can add up very fast.


--
HTH
Kalen Delaney, SQL Server MVP


[quoted text, click to view]

Re: Size of column of datatype Image Erland Sommarskog
7/23/2006 6:41:51 PM
Kalen Delaney (replies@public_newsgroups.com) writes:
[quoted text, click to view]

Oops! I did mean bytes, honestly! Must be a problem with my keyboard!

[quoted text, click to view]

Thanks for the correction, Kalen.


--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
AddThis Social Bookmark Button