Games & Quizzes
Don't forget to Sign In to save your points
This is a modal window.
PERFECT HITS | +NaN | |
HITS | +NaN | |
LONGEST STREAK | +NaN | |
TOTAL | + |
Hey guys, I am Venkat and in this video, we'll understand how sql server stores data internally.
As a software engineer this knowledge is very important, especially if you want to troubleshoot
and fix sql queries that are not performing very well from performance standpoint. Along the way,
we'll also understand some of the common technical terms like the following - Data pages,
root node, leaf nodes, b tree and clustered index structure. Understanding these terms is very
important, especially if you're doing something related to sql server performance tuning. Now,
have you ever wondered how sql server physically stores table data internally? Well, data in tables
is stored in row and column format at the logical level but physically it stores data in something
called data pages. A data page is the fundamental unit of data storage in sql server and it is eight
kilobytes in size. When we insert any data into sql server database table, it saves that data to
a series of 8 kilobytes data pages. So, table data in sql server is actually stored in a tree-like
structure. Let's understand this with a simple example. Consider this Employees table. In this
table EmployeeId is the primary key column. So, by default, a clustered index on this
EmployeeId column is created. This means, the data is physically stored in the database is sorted by
EmployeeId column. Now, where is the data actually stored? Well, it is stored in a series of data
pages in a tree-like structure that looks like the following. This tree-like structure is called
B-tree, Index B-Tree or clustered index structure, all these three terms mean the same thing.
The nodes that you see at the bottom of the tree are called data pages or leaf nodes of the tree
and it is these leaf nodes that contain our table data. The size of each data page is 8 kilobytes,
this means the number of rows that are stored in each data page really depends on the size of each
/ˈkēləˌbīt/
unit of memory or data equal to 1,024 bytes. Units of information equal to 1024 bytes.
/ˌenjəˈnir/
Someone whose job is designing machines, buildings. design and build.
/ˈfälōiNG/
Next; the one after this. body of supporters or admirers. coming after or as a result. To come after someone; be guided by someone.
/ˈkwirē/
question. Questions asked in order to remove doubts. To ask a question, e.g. because you have doubts.