SQL Server architecture ( Interview )

What is SQL Architecture ?? , What are its components , Define SQL Architecture?? 


Today I thought to update my first article of SQL Architecture.

All these are common interview questions but more over we should know this to understand , how SQL works

 http://saurabhsinhainblogs.blogspot.in/

SQL server is divided into 4 layers



      When an application communicates with the SQL Server Database Engine, the application programming interfaces (APIs) exposed by the protocol layer formats the communication using a Microsoft-defined format called a tabular data stream (TDS) packet. There are Net-Libraries on both the server and client computers that encapsulate the TDS packet inside a standard communication protocol, such as TCP/IP or Named Pipes.

      1. TCP/IP; The most widely used protocol over the Internet. TCP/IP can communicate across interconnected networks of computers with diverse hardware architectures and operating systems. It includes standards for routing network traffic and offers advanced security features. Enabling SQL Server to use TCP/IP requires the most configuration effort, but most networked computers are already properly configured.

      2. Named Pipes: A protocol developed for local area networks (LANs). A portion of memory is used by one process to pass information to another process, so that the output of one is the input of the other. The second process can be local (on the same computer as the first) or remote (on a networked computer).

      3. Shared Memory: The simplest protocol to use, with no configurable settings. Clients using the Shared Memory protocol can connect only to a SQL Server instance running on the same computer, so this protocol is not useful for most database activity. Use this protocol for troubleshooting when you suspect that the other protocols are configured incorrectly. Clients using MDAC 2.8 or earlier cannot use the Shared Memory protocol.

      4. VIA (Virtual Interface Adapter): A protocol that works with VIA hardware. This is a specialized protocol; configuration details are available from your hardware vendor.

      Query Processor: 


      A relational database consists of many parts, but at its heart are two major components: the storage engine and the query processor. The query processor is that portion of SQL Server that accepts, parses, and executes SQL syntax

      1. Parser: The parser handles Transact-SQL language events sent to SQL Server. It checks for proper syntax and translates Transact-SQL commands into an internal format that can be operated on. This internal format is known as a query tree. If the parser doesn’t recognize the syntax, a syntax error is immediately raised that identifies where the error occurred. However, non-syntax error messages cannot be explicit about the exact source line that caused the error. Because only the command parser can access the source of the statement, the statement is no longer available in source format when the command is actually executed.
      2. Optimizer: The query optimizer takes the query tree from the command parser and prepares it for execution. Statements that can’t be optimized, such as flow-of-control and DDL commands, are compiled into an internal form. The statements that are optimizable are marked as such and then passed to the optimizer. The optimizer is mainly concerned with the DML statement SELECT, INSERT, UPDATE, and DELETE, which can be processed in more than one way, and it is the optimizer’s job to determine which of the many possible ways is the best. It compiles an entire command batch, optimizes queries that are optimizable, and checks security. The query optimization and compilation result in an execution plan.
      3. SQL Manager: The SQL manager is responsible for everything related to managing stored procedures and their plans. It determines when a stored procedure needs recompilation, and it manages the caching of procedure plans so that other processes can reuse them. The SQL manager also handles auto parameterization of queries. In SQL Server 2008, certain kinds of ad hoc queries are treated as if they were parameterized stored procedures, and query plans are generated and saved for them. SQL Server can save and reuse plans in several other ways, but in some situations using a saved plan might not be a good idea.
      4. Database Manager: The database manager handles access to the metadata needed for query compilation and optimization, making it clear that none of these separate modules can be run completely separately from the others. The metadata is stored as data and is managed by the storage engine, but metadata elements such as the data types of columns and the available indexes on a table must be available during the query compilation and optimization phase, before actual query execution starts.
      5. Query Executer: The query executor runs the execution plan that the optimizer produced, acting as a dispatcher for all the commands in the execution plan. This module steps through each command of the execution plan until the batch is complete. Most of the commands require interaction with the storage engine to modify or retrieve data and to manage transactions and locking.


    • Storage Engine


    1.Transaction Services
    2.Lock Manger
    3.Buffer Manager
    4.File Manager
    5.Acess Methods for pages / versions /indexes / allocation
    6.Utilities bulkload / dbcc / backup / restore

    • SQL OS


    1.Deadlock Monitor
    2.Resource monitor
    3.Lazy Writer
    4.Schedule Monitor
    5.Lock Manger
    6.Synchronize Services
    7.Schedule
    8.Memory manger
    9.Buffer pool
    10.I/O
    11.Sql OS hosting API





    1 comment:
    Write comments
    1. Is there any diagram for architecture that shows all the background processes and step by step methods that SQL uses to execute a query and provide the output? Thanks..

      ReplyDelete

    Please do not enter spam links

    Meet US

    Services

    More Services