SQL Server Layers: Protocols, Query Processor, Storage Engine and SQLOS

SQL Server layers run from the network protocols at the top to the files at the bottom. The diagram below shows the main ones: protocols, the query processor, the storage engine and SQLOS. It is a generic picture of the engine.

Diagram of the SQL Server layers: external protocols on top, then the database engine with the query processor and the storage engine, then SQLOS, and the MDF and LDF files on disk at the bottom

What Each Layer Does

Clients reach SQL Server through the external protocols: Shared Memory, Named Pipes, TCP/IP and the Virtual Interface Adapter (VIA). The database engine sits behind them and has two parts.

The query processor turns a query into a plan and runs it. It holds the parser, the optimizer, the SQL manager, the database manager and the query executor. The storage engine reads and writes the data. It holds transaction services and the file, buffer and lock managers. Its access methods cover rows, indexes, versions, pages and allocations. Utilities such as bulk load, DBCC and backup and restore live here too.

SQLOS sits under both parts. It provides the thread scheduler, the memory manager, the buffer pool and the I/O manager. Background worker threads, such as the lazy writer and the resource monitor, run on top of it.

Physical Architecture

The physical structure of a database is divided into the MDF and the LDF. The MDF part contains the file group, the data files, tables and indexes, extents and pages. The LDF file contains the transaction log.

Physical architecture is about how the data is stored in the file system. Pages, extents and database files all belong to it.

Logical Architecture

Logical architecture is about how the data is grouped and shown to the end user. It contains tables, constraints, stored procedures, functions and other objects.

Pages and Extents

The page is the smallest unit of storage in SQL Server, and it is 8 KB. An extent holds 8 adjacent pages. There are two types of extents: uniform and mixed.

A new table or index is usually allocated its pages from mixed extents. Once it grows past 64 KB, or 8 pages, its storage changes from mixed to uniform extents.

Quick reference card: SQL Server layers

A layer is not a product, it is a job inside the engine.

Published by Pinal Dave on SQLAuthority. More of my work at pinaldave.com.


Discover more from SQL Authority with Pinal Dave

Subscribe to get the latest posts sent to your email.

Database, SQL Data Storage, SQL Server, SQL Server Architecture
Previous Post
SQL SERVER – FIX : Error : 3702 Cannot drop database because it is currently in use.
Next Post
SQL SERVER – ACID (Atomicity, Consistency, Isolation, Durability)

Related Posts

20 Comments. Leave new

  • Hi Pinal,

    It seems like in all the SQL Server DBA interviews they ask can you explain the SQL Server Architecture. Dose that mean they are expecting to explain the above architecture is full i mean each component ??

    Many Thanks,
    Arun

    Reply
  • hi pinal ,
    just give me explanation about architecture diagram..

    Reply
  • Hi Pinal,

    Need to know more about the architecture from you.

    Regards
    Manish

    Reply
  • Hi Pinal,

    Could you briefly explain the above diagram.

    Regards
    Ramesh

    Reply
  • I required explanation because i want it in my project

    Reply
  • Hi Pinal Dave,
    please give me explanation about each topic in above diagram.

    Reply
  • Hi Pinal Dave,
    please give me explanation about each topic in above diagram.

    From

    Tirumala

    Reply
  • Sarika Salunkhe
    April 26, 2011 12:34 pm

    Hi Pinal,

    Would request you to provide the brief explanation of the above SQL server architecture diagram.

    Thanks & Regards,
    Sarika

    Reply
  • Hi Pinal,

    I attended your today’s (Teched) session in Pune, and it was a very nice experience to be there. I learned so many new thing.
    Thanks a lot for all your efforts for the community.

    And I am looking forward to attend your upcoming session in coming future.

    and once more I would like to request you to please write some more about about the above mentioned SQL Server architecture.

    Thanks
    Manish

    Reply
  • Hi Pinal

    i am working as a sql server developer.
    u r blog will helps and give more stuff who are intrested to know about database.

    how funny u see even i dodnt know sql server architecture
    but i am working as a sql server developer

    please give me explanation for the above architecture

    Thanks Pinal thanks for u r blog

    Reply
  • u konw u r the hero for our people, like me most of the people

    we admire u

    Reply
  • Hi Pinal,

    Please give me the explaination of architecture diagram…

    Thanks

    Reply
  • shall we install sql server in linux

    Reply
    • @Pavan, this is one of the drawback of Sql server. i.e., it doesn’t support any other OS except Windows Versions.

      Reply
  • Hey Pavan,

    No I believe, you can’t install SQL Server in linux.

    Thanks
    Manish

    Reply
  • Vishwa

    Reply
  • even i was asked in interview how query fetches data from Database engine

    Reply
  • plz explain the above diagram..

    Reply
  • Prashant Kumar
    May 29, 2012 9:48 pm

    For the folks who are interested in the ‘explanation’ of the above diagram, the diagram is straight (the only difference is above is colorful) from Kalen Delaney’s book “inside Microsoft SQL Server 2000” Chapter 3.1. Looks for the complete explanation there.

    Reply
  • great prashant,
    Pinal you have done great job .

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

Fill out this field
Fill out this field
Please enter a valid email address.