문제

Do you know what is the difference between the database engine get rows in a table without and with use of an index in a disk prespective. They way the engine access the table in disk is the same when use and dont use index? Or when the database engine dont use index the access to disk is sequential, and when use index the access is random and consequently slower?

도움이 되었습니까?

해결책

The SQL Server DB Storage Engine access the data on the hard drive the same way. It can be the exact same physical file. This is why although it's bad practice, you can have just 1 physical .mdf file and have all of your indexed, non indexed data on a clustered index, and heap in the same physical file. Of course performance and disk space usage will be different given how a proper covering index can increase performance at the expense of disk space and RAM utilization.

SQL Server's storage engine then uses the SGAM, GAM, and PFS which will find the type of extent (mixed or not), which extent, and pages which the data is written to in the SQL Server database file regardless if you have a index on a table (heap or clustered) or not.

The logical methods in which it uses to get the data typically matter if the table is a heap (unsorted) or has a clustered index. In the case of a heap you have a RID (Row ID) which identifies every single row. In a clustered index you have the index key which it efficiently uses the reverse b-tree index to traverse down to.

Paul Randall, the head of the Storage Engine team in SQL 2005 describes it all very well here if you wanted to dig into the internals: Inside the storage engine Paul's MCM videos on this topic go through the internals in a easy to understand way.

You'll want to review "Data File Internals and Maintenance", "Index Internals", and maybe "The Clustered Index Debate" if you're feeling up for it.

Good luck!

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 dba.stackexchange
scroll top