Library

Video Player is loading.
 
Current Time 0:00
Duration 7:04
Loaded: 0.00%
 

x1.00


Back

Games & Quizzes

Training Mode - Typing
Fill the gaps to the Lyric - Best method
Training Mode - Picking
Pick the correct word to fill in the gap
Fill In The Blank
Find the missing words in a sentence Requires 5 vocabulary annotations
Vocabulary Match
Match the words to the definitions Requires 10 vocabulary annotations

You may need to watch a part of the video to unlock quizzes

Don't forget to Sign In to save your points

Challenge Accomplished

PERFECT HITS +NaN
HITS +NaN
LONGEST STREAK +NaN
TOTAL +
- //

We couldn't find definitions for the word you were looking for.
Or maybe the current language is not supported

  • 00:02

    Hey guys, I am Venkat and in this video, we'll  understand how sql server stores data internally.  
    Hey guys, I am Venkat and in this video, we'll  understand how sql server stores data internally.  

  • 00:10

    As a software engineer this knowledge is very  important, especially if you want to troubleshoot  
    As a software engineer this knowledge is very  important, especially if you want to troubleshoot  

  • 00:16

    and fix sql queries that are not performing very  well from performance standpoint. Along the way,  
    and fix sql queries that are not performing very  well from performance standpoint. Along the way,  

  • 00:22

    we'll also understand some of the common  technical terms like the following - Data pages,  
    we'll also understand some of the common  technical terms like the following - Data pages,  

  • 00:27

    root node, leaf nodes, b tree and clustered index  structure. Understanding these terms is very  
    root node, leaf nodes, b tree and clustered index  structure. Understanding these terms is very  

  • 00:35

    important, especially if you're doing something  related to sql server performance tuning. Now,  
    important, especially if you're doing something  related to sql server performance tuning. Now,  

  • 00:42

    have you ever wondered how sql server physically  stores table data internally? Well, data in tables  
    have you ever wondered how sql server physically  stores table data internally? Well, data in tables  

  • 00:49

    is stored in row and column format at the logical  level but physically it stores data in something  
    is stored in row and column format at the logical  level but physically it stores data in something  

  • 00:56

    called data pages. A data page is the fundamental  unit of data storage in sql server and it is eight  
    called data pages. A data page is the fundamental  unit of data storage in sql server and it is eight  

  • 01:03

    kilobytes in size. When we insert any data into  sql server database table, it saves that data to  
    kilobytes in size. When we insert any data into  sql server database table, it saves that data to  

  • 01:09

    a series of 8 kilobytes data pages. So, table data  in sql server is actually stored in a tree-like  
    a series of 8 kilobytes data pages. So, table data  in sql server is actually stored in a tree-like  

  • 01:18

    structure. Let's understand this with a simple  example. Consider this Employees table. In this  
    structure. Let's understand this with a simple  example. Consider this Employees table. In this  

  • 01:24

    table EmployeeId is the primary key column.  So, by default, a clustered index on this  
    table EmployeeId is the primary key column.  So, by default, a clustered index on this  

  • 01:31

    EmployeeId column is created. This means, the data  is physically stored in the database is sorted by  
    EmployeeId column is created. This means, the data  is physically stored in the database is sorted by  

  • 01:38

    EmployeeId column. Now, where is the data actually  stored? Well, it is stored in a series of data  
    EmployeeId column. Now, where is the data actually  stored? Well, it is stored in a series of data  

  • 01:45

    pages in a tree-like structure that looks like  the following. This tree-like structure is called  
    pages in a tree-like structure that looks like  the following. This tree-like structure is called  

  • 01:52

    B-tree, Index B-Tree or clustered index structure,  all these three terms mean the same thing.  
    B-tree, Index B-Tree or clustered index structure,  all these three terms mean the same thing.  

  • 01:59

    The nodes that you see at the bottom of the tree  are called data pages or leaf nodes of the tree  
    The nodes that you see at the bottom of the tree  are called data pages or leaf nodes of the tree  

  • 02:06

    and it is these leaf nodes that contain our table  data. The size of each data page is 8 kilobytes,  
    and it is these leaf nodes that contain our table  data. The size of each data page is 8 kilobytes,  

  • 02:13

    this means the number of rows that are stored in  each data page really depends on the size of each  
    this means the number of rows that are stored in  each data page really depends on the size of each  

  • 02:20

    row. For our example, let's say in this Employees  table we have 1200 rows and let's assume in  
    row. For our example, let's say in this Employees  table we have 1200 rows and let's assume in  

  • 02:27

    each data page we have 200 rows but in reality  depending on the actual row size, we may have more  
    each data page we have 200 rows but in reality  depending on the actual row size, we may have more  

  • 02:34

    or less rows, but for this example sake, let's  assume each data page has 200 rows. Remember, the  
    or less rows, but for this example sake, let's  assume each data page has 200 rows. Remember, the  

  • 02:42

    important point to keep in mind is, the rows in  these data pages are sorted by EmployeeId column,  
    important point to keep in mind is, the rows in  these data pages are sorted by EmployeeId column,  

  • 02:50

    because EmployeeId is the primary key of our table  and hence the clustered key. So, in the first data  
    because EmployeeId is the primary key of our table  and hence the clustered key. So, in the first data  

  • 02:57

    page, we have 1 to 200 rows, in the second 201 to  400, in the third 401 to 600 so on and so forth.  
    page, we have 1 to 200 rows, in the second 201 to  400, in the third 401 to 600 so on and so forth.  

  • 03:08

    The node at the top of the tree is called root  node. The nodes between the root node and the leaf  
    The node at the top of the tree is called root  node. The nodes between the root node and the leaf  

  • 03:15

    nodes are called intermediate levels. There can  be multiple intermediate levels. In our example,  
    nodes are called intermediate levels. There can  be multiple intermediate levels. In our example,  

  • 03:21

    we have just 1200 rows and to keep this example  simple, I included just one intermediate level,  
    we have just 1200 rows and to keep this example  simple, I included just one intermediate level,  

  • 03:28

    but in reality, the number of intermediate  levels depends on the number of rows you  
    but in reality, the number of intermediate  levels depends on the number of rows you  

  • 03:33

    have in the underlying database table. The  root and the intermediate level nodes contain  
    have in the underlying database table. The  root and the intermediate level nodes contain  

  • 03:39

    index rows and the leaf nodes, that is nodes  at the bottom of the tree, contain the actual  
    index rows and the leaf nodes, that is nodes  at the bottom of the tree, contain the actual  

  • 03:46

    data rows. Each index row contains a key  value, in our case EmployeeId and a pointer  
    data rows. Each index row contains a key  value, in our case EmployeeId and a pointer  

  • 03:53

    to either an intermediate level page in the  B-tree or a data row in the leaf node. So, the  
    to either an intermediate level page in the  B-tree or a data row in the leaf node. So, the  

  • 04:01

    important point is, this tree-like structure has a  series of pointers that helps the database engine  
    important point is, this tree-like structure has a  series of pointers that helps the database engine  

  • 04:08

    find the data quickly. For example, let's say we  want to find employee row with EmployeeId = 1120.  
    find the data quickly. For example, let's say we  want to find employee row with EmployeeId = 1120.  

  • 04:16

    So, the query itself is very simple - Select  * from employees where employee id = 1120. So,  
    So, the query itself is very simple - Select  * from employees where employee id = 1120. So,  

  • 04:26

    the database engine starts at the root node and  from there it picks the index node on the right  
    the database engine starts at the root node and  from there it picks the index node on the right  

  • 04:31

    because the database engine knows it is this node  that contains EmployeeIds from 801 to 1200. From  
    because the database engine knows it is this node  that contains EmployeeIds from 801 to 1200. From  

  • 04:40

    there, it picks the leaf node that is present  on the extreme right because employee data rows  
    there, it picks the leaf node that is present  on the extreme right because employee data rows  

  • 04:46

    from 1001 to 1200 are present in this leaf  node. The data rows in the leaf node are sorted  
    from 1001 to 1200 are present in this leaf  node. The data rows in the leaf node are sorted  

  • 04:54

    by EmployeeId, so it's easy for the database  engine to find the employee row with Id = 1120.  
    by EmployeeId, so it's easy for the database  engine to find the employee row with Id = 1120.  

  • 05:01

    Notice, in just three operations sql server is  able to find the data we are looking for. So, the  
    Notice, in just three operations sql server is  able to find the data we are looking for. So, the  

  • 05:07

    point is, if there are thousands or even millions  of records, sql server can easily and quickly  
    point is, if there are thousands or even millions  of records, sql server can easily and quickly  

  • 05:13

    find the data we are looking for provided there  is an index that can help the query find data.  
    find the data we are looking for provided there  is an index that can help the query find data.  

  • 05:19

    In this specific example, there is a clustered  index on EmployeeId column. So, when we search  
    In this specific example, there is a clustered  index on EmployeeId column. So, when we search  

  • 05:25

    by EmployeeId, sql server can easily and  quickly find the data we are looking for,  
    by EmployeeId, sql server can easily and  quickly find the data we are looking for,  

  • 05:30

    but what if we search by employee name? At the  moment, there is no index on the Name column,  
    but what if we search by employee name? At the  moment, there is no index on the Name column,  

  • 05:36

    so there is no easy way for sql server to  find the data we are looking for. SQL server  
    so there is no easy way for sql server to  find the data we are looking for. SQL server  

  • 05:41

    has to read every record in the table which is  extremely inefficient from performance standpoint.  
    has to read every record in the table which is  extremely inefficient from performance standpoint.  

  • 05:47

    This is when we create a non-clustered index on  the Name column. In our next video in the series,  
    This is when we create a non-clustered index on  the Name column. In our next video in the series,  

  • 05:54

    we'll discuss, how the index and table  data is physically stored when we have both  
    we'll discuss, how the index and table  data is physically stored when we have both  

  • 05:59

    a non-clustered index and a clustered index.  We'll also discuss - Index Seek and Index Scan.  
    a non-clustered index and a clustered index.  We'll also discuss - Index Seek and Index Scan.  

  • 06:06

    Understanding these two concepts is very important  especially when we are tuning sql queries  
    Understanding these two concepts is very important  especially when we are tuning sql queries  

  • 06:12

    for better performance. We'll see all these  practically in action in our next video, so please  
    for better performance. We'll see all these  practically in action in our next video, so please  

  • 06:19

    stay tuned. Before we wrap up, if you're new to  sql server indexes we have already discussed them  
    stay tuned. Before we wrap up, if you're new to  sql server indexes we have already discussed them  

  • 06:24

    in detail in our sql server tutorial for beginners  course. Please check out the videos from Parts 35  
    in detail in our sql server tutorial for beginners  course. Please check out the videos from Parts 35  

  • 06:31

    to 38. I'll include the link to this  course in the description of this video.  
    to 38. I'll include the link to this  course in the description of this video.  

  • 06:36

    I hope you found this video useful. That's  it in this video and thank you for listening.
    I hope you found this video useful. That's  it in this video and thank you for listening.

All idiom
I am
//

idiom

Modeled on the phrase "I am woman, hear me roar" from the 1972 song “I am Woman” by Helen Reddy. Either used genuinely as a phrase of empowerment for some person, or else used humorously or sarcastically to deride or poke fun at someone.

How is data stored in sql database

91,057 views

Video Language:

  • English

Caption Language:

  • English (en)

Accent:

  • English (UK)

Speech Time:

95%
  • 6:43 / 7:03

Speech Rate:

  • 151 wpm - Fast

Category:

  • Science & Technology

Intro:

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  

Video Vocabulary

/ˈwəndər/

verb

desire to know something.

/ˈkēləˌbīt/

noun other

unit of memory or data equal to 1,024 bytes. Units of information equal to 1024 bytes.

/ˌenjəˈnir/

noun verb

Someone whose job is designing machines, buildings. design and build.

/ˈfälōiNG/

adjective noun preposition verb

Next; the one after this. body of supporters or admirers. coming after or as a result. To come after someone; be guided by someone.

/imˈpôrtnt/

adjective

Having power or authority.

/ˈkwirē/

noun other verb

question. Questions asked in order to remove doubts. To ask a question, e.g. because you have doubts.

/ˈdadəˌbās/

noun

Data stored in logical order to aid retrieval.

/kənˈtān/

verb

To hold something inside something else.

/ˈnäləj/

noun

information and skills acquired through experience and education.

/dəˈpend/

verb

Be controlled or determined by..

/ˈteknək(ə)l/

adjective noun

Of practical use of machine/science in industry. undefined.

/iɡˈzampəl/

noun verb

thing characteristic of its kind. be illustrated or exemplified.

/dəˈpend/

verb

Be able to trust; rely on..