rows on a page

Sorry - -a little new to SQL Server, but I see there is a single choice of a page at 8KB. Is there a limit to the # of rows I can get on a page outside of calculating header information and the size of each row? I know that DB2 (and I think Oracle) have actual architecual limits on the number of rows on a page no matter how much space they take up.
[402 byte] By [learningdba] at [2008-2-25]
# 1
In case of data pages (leaf pages of a B-Tree or heap pages), the minimum row size is 9 bytes, so at most you can fit around 900 rows on a page.

For index pages (internal pages of the B-Tree) the minimum row size is around 4 bytes, so you can fit around 2000 rows on a page.

In most cases though, row sizes are much larger than I listed here, and thus you will be able to fit less rows on a page. It all depends on the data.

Thanks,

MarcelvanderHolst-MSFT at 2007-10-2 > top of Msdn Tech,SQL Server Katmai,SQL Server Katmai Database Engine...
# 2
And of course compression will change this too -- as will the data types. So let me ask this a different way -- is there an architectual limit as to the # of rows on a page for rows atomically? Or is it always a function of size less the overhead of a page. For example, in DB2 v8 I can reall that I had a limit of 255 rows per page ....
learningdba at 2007-10-2 > top of Msdn Tech,SQL Server Katmai,SQL Server Katmai Database Engine...
# 3
Actually, compression will not change this much, as the 9 byte limit is independent of compression.

The number of rows on a page is calculated as follows:

1) Take the page size (8K)
2) Remove the page header overhead (96 bytes)
3) Remove the compression info overhead (variable size in case of compression, 0 in case of no compression)
4) For each row, you have 2 bytes overhead for the offset pointeer
5) For data rows, the minimum size of a record is 9 bytes
6) For index rows (internal b-tree nodes), the minimum si13ze of a record is 4 bytes.

Taking index rows as example, each row takes 6 bytes (4 bytes record + 2 bytes offset). We have 8096 bytes for data (page size - header), meaning that theoratically, you can fit 8096 / 6 = 1349 rows on a page.

For data rows, you can fit a maximum of 8096 / 11 = 736 rows.

Thanks,

MarcelvanderHolst-MSFT at 2007-10-2 > top of Msdn Tech,SQL Server Katmai,SQL Server Katmai Database Engine...

SQL Server Katmai

Site Classified