SQL Server Architecture is a very deep subject. Covering it in a single post is an almost impossible task. However, this subject is very popular topic among beginners and advanced users. I have requested my friend Anil Kumar who is expert in SQL Domain to help me write a simple post about Beginning SQL Server Architecture. As stated earlier this subject is very deep subject and in this first article series he has covered basic terminologies. In future article he will explore the subject further down. Anil Kumar Yadav is Trainer, SQL Domain, Koenig Solutions. Koenig is a premier IT training firm that provides several IT certifications, such as Oracle 11g, Server+, RHCA, SQL Server Training, Prince2 Foundation etc.
In this Article we will discuss about MS SQL Server architecture.
The major components of SQL Server are:
- Relational Engine
- Storage Engine
- SQL OS
Now we will discuss and understand each one of them.
1) Relational Engine: Also called as the query processor, Relational Engine includes the components of SQL Server that determine what your query exactly needs to do and the best way to do it. It manages the execution of queries as it requests data from the storage engine and processes the results returned.
Different Tasks of Relational Engine:
- Query Processing
- Memory Management
- Thread and Task Management
- Buffer Management
- Distributed Query Processing
2) Storage Engine: Storage Engine is responsible for storage and retrieval of the data on to the storage system (Disk, SAN etc.). to understand more, let’s focus on the concepts.
When we talk about any database in SQL server, there are 2 types of files that are created at the disk level – Data file and Log file. Data file physically stores the data in data pages. Log files that are also known as write ahead logs, are used for storing transactions performed on the database.
Let’s understand data file and log file in more details:
Data File: Data File stores data in the form of Data Page (8KB) and these data pages are logically organized in extents.
Extents: Extents are logical units in the database. They are a combination of 8 data pages i.e. 64 KB forms an extent. Extents can be of two types, Mixed and Uniform. Mixed extents hold different types of pages like index, system, data etc (multiple objects). On the other hand, Uniform extents are dedicated to only one type (object).
Pages: As we should know what type of data pages can be stored in SQL Server, below mentioned are some of them:
- Data Page: It holds the data entered by the user but not the data which is of type text, ntext, nvarchar(max), varchar(max), varbinary(max), image and xml data.
- Index: It stores the index entries.
- Text/Image: It stores LOB ( Large Object data) like text, ntext, varchar(max), nvarchar(max), varbinary(max), image and xml data.
- GAM & SGAM (Global Allocation Map & Shared Global Allocation Map): They are used for saving information related to the allocation of extents.
- PFS (Page Free Space): Information related to page allocation and unused space available on pages.
- IAM (Index Allocation Map): Information pertaining to extents that are used by a table or index per allocation unit.
- BCM (Bulk Changed Map): Keeps information about the extents changed in a Bulk Operation.
- DCM (Differential Change Map): This is the information of extents that have modified since the last BACKUP DATABASE statement as per allocation unit.
Log File: It also known as write ahead log. It stores modification to the database (DML and DDL).
- Sufficient information is logged to be able to:
- Roll back transactions if requested
- Recover the database in case of failure
- Write Ahead Logging is used to create log entries
- Transaction logs are written in chronological order in a circular way
- Truncation policy for logs is based on the recovery model
SQL OS: This lies between the host machine (Windows OS) and SQL Server. All the activities performed on database engine are taken care of by SQL OS. It is a highly configurable operating system with powerful API (application programming interface), enabling automatic locality and advanced parallelism. SQL OS provides various operating system services, such as memory management deals with buffer pool, log buffer and deadlock detection using the blocking and locking structure. Other services include exception handling, hosting for external components like Common Language Runtime, CLR etc.
I guess this brief article gives you an idea about the various terminologies used related to SQL Server Architecture. In future articles we will explore them further.
The author of the article is Anil Kumar Yadav is Trainer, SQL Domain, Koenig Solutions. Koenig is a premier IT training firm that provides several IT certifications, such as Oracle 11g, Server+, RHCA, SQL Server Training, Prince2 Foundation etc.
Reference: Pinal Dave (http://blog.sqlauthority.com)