Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 SQL Server Administration (2005)
 data page and RID

Author  Topic 

aakcse
Aged Yak Warrior

570 Posts

Posted - 2009-07-14 : 06:58:34
Hi all,

As we know that sqlengine access the row from the data pages with the help of,page header and offset, however how sqlengine will come to know if it has to access a particular column value in a row?

What is the size of Rowid RID and wht does it contains?

Regards,
a

ahmad.osama
Posting Yak Master

183 Posts

Posted - 2009-07-14 : 07:47:29
quote:
Originally posted by aakcse

Hi all,

As we know that sqlengine access the row from the data pages with the help of,page header and offset, however how sqlengine will come to know if it has to access a particular column value in a row?

What is the size of Rowid RID and wht does it contains?

Regards,
a




We can classify the tables as Clustered table and a Heap.

1) Clustered table: table wid clustered index.In this case a row is located using clustered index key.
2) Heap: Table wid out clustered index. In this case a row is located using a row id which is created based on the extents,pages and row offset for that row.

hope this answers the question...
Go to Top of Page

aakcse
Aged Yak Warrior

570 Posts

Posted - 2009-07-14 : 10:06:01
Thanks Mr. Ahmad,
however, my question is different, as per my understanding page contains offset with tell where the row begin and where it ends.
and I wud like to know how the sqlengine determine, particular colum data for a row in question.

for the second,I will try and google.

Thanks,
aak
Go to Top of Page

ahmad.osama
Posting Yak Master

183 Posts

Posted - 2009-07-14 : 13:24:32
quote:
Originally posted by aakcse

Thanks Mr. Ahmad,
however, my question is different, as per my understanding page contains offset with tell where the row begin and where it ends.
and I wud like to know how the sqlengine determine, particular colum data for a row in question.

for the second,I will try and google.

Thanks,
aak



Let me explain it a bit more......I wud show u how a page is structured in sql server

below dbcc commands are undocumnented commands ... u can google them for details...

use dbcc ind(dbid,tableid,-1)

look in pagetype column for a value of 1.select the corresponding
pagepid.

dbcc traceon(3604)
go
dbcc page(dbid,fileid,pagepid,3)

u will get an output as give below...some info is removed for clarity.

as u can see that each column has an offset information which is used by sql server to access particular column value in a row.



Slot 0 Column 1 Offset 0x2e Length 6

LastName = Adkins

Slot 0 Column 2 Offset 0x34 Length 50

FirstName =

Slot 0 Column 3 Offset 0x4 Length 4

Empid = 244123

Slot 0 Column 4 Offset 0x8 Length 4

DeptID = 244123

Slot 0 Column 5 Offset 0x66 Length 12

MiddleName = Gabriel Mayo

Slot 0 Column 6 Offset 0xc Length 8

DateOfBirth = Dec 15 1960 11:08AM

Slot 0 Column 7 Offset 0x14 Length 8

DateOfJoining = Jul 11 1992 11:19AM
EmpSystemID = [NULL]



Also... size of a row id.. size of clustered index key in case of a clustered index and it depends on extent,page and offset when table is a heap.

hope this answers your question...
Go to Top of Page

aakcse
Aged Yak Warrior

570 Posts

Posted - 2009-07-15 : 08:56:24
Thanks for the explaination, can you put more light on this.. still I am confuse with how the sqlengine reachs the column, as the above commands are not working on my sqlserver db.

Go to Top of Page

ahmad.osama
Posting Yak Master

183 Posts

Posted - 2009-07-15 : 13:15:01
quote:
Originally posted by aakcse

Thanks for the explaination, can you put more light on this.. still I am confuse with how the sqlengine reachs the column, as the above commands are not working on my sqlserver db.




Execute the below given code and post the result of DBCC page..

create table employee(empid int identity(1,1),empname varchar(50),Dateofjoining datetime)

Insert into employee values('John',getdate())
Insert into employee values('Rose',getdate())
Insert into employee values('Sachin',getdate())
Insert into employee values('Ramsey',getdate())
Insert into employee values('Sharukh',getdate())
Insert into employee values('Salman',getdate())
Insert into employee values('Maria',getdate())
Insert into employee values('Janelia',getdate())
select * from sys.sysfiles
select file_id('newdb')

Declare @dbid int,@Tableid int
select @dbid=db_id(),@Tableid=object_id('Employee')
-- lists all the pages for a particular
Dbcc ind(@dbid,@Tableid,-1)
Dbcc TraceOn(3604)
--dbcc page(@dbid,fileid,pagepid,3)
--@dbid=@dbid;fileid=id of the datafile from sys.sysfiles;pagepid=pagepid from dbcc ind output where pagetype=1;
Dbcc Page(@dbid,1,158,3)
Go to Top of Page

rezmar
Starting Member

1 Post

Posted - 2010-01-06 : 13:37:20
RID size is 8 bytes
Go to Top of Page
   

- Advertisement -