Technical Integration Department System Analysis & Training Group Jerry Yang August 25, 2005 SQL Server 2000 Research Series  Architecture Overview
Introduction Operating Environment  The SQL Server Engine Memory Management Transaction Logging And Recovery  Summary Agenda
Introduction Operating Environment  The SQL Server Engine Memory Management Transaction Logging And Recovery Summary Architectural Overview
Introduction What Is It ? Why Analyze Architecture ? Processing Procedures Performance Issues Hardware Deploy Software Implementation How Should We Proceed ? DBMS Structure SQL Server Components Relationships
DBMS – Database Management Systems Introduction Application Programs/Queries Software to Process Queries/Programs Software to Access Stored Data Users/Programmers DATABASE SYSTEM DBMS SOFTWARE Stored Database Definition (Meta-Data) Stored Database
Introduction Operating Environment   The SQL Server Engine Memory Management Transaction Logging And Recovery Summary Architectural Overview
Service Manager Enterprise Manager Query Analyzer SQL Server Profiler DTS - Data Transformation Services Client Network Utility Operating Environment
Service Manager Enterprise Manager Query Analyzer SQL Server Profiler DTS - Data Transformation Services Client Network Utility  Operating Environment
Service Manager Operating Environment
Enterprise Manager Operating Environment
Enterprise Manager (Continued) Operating Environment
Query Analyzer Operating Environment
Query Analyzer (Continued) Operating Environment
Introduction Operating Environment  The SQL Server Engine Memory Management Transaction Logging And Recovery Summary Architectural Overview
The SQL Server Engine SQL Server Architecture Net-Library User Mode Scheduler Relational Engine OLE & Non-OLE DB Communication Storage Engine I/O Manager Win 32 API
The SQL Server Engine SQL Server Architecture Net-Library User Mode Scheduler Relational Engine OLE & Non-OLE DB Communication Storage Engine I/O Manager Win 32 API
The SQL Server Engine SQL Server Architecture (Continued)
The SQL Server Engine Net-Library Functionality An abstraction layer  enables SQL Server to  read from and write to  many different network  protocols. Advantage Support many network protocols without having to change the core server code.
The SQL Server Engine Net-Library (Continued) Primary Net-Libraries Members OLE DB Provider for SQL Server SQL Server ODBC Driver Super Socket & Shared Memory Inter-computer Connection Local Connection Secondary Net-Libraries Members TCP/IP IPX/SPX ETC.
The SQL Server Engine Net-Library (Continued) Operating Environment
The SQL Server Engine Net-Library (Continued) Operating Environment
The SQL Server Engine Relational Engine Functionality Comprises all the components necessary to parse and optimize any query. Manages the execution of queries as it requests data from the storage engine in terms of OLE DB row sets and then processes the row sets returned.
The SQL Server Engine Relational Engine ODS ( O pen  D ata  S ervices)
The SQL Server Engine Relational Engine ODS (Continued) Functionality An interface between server Net-Library and server-based applications. Connection Handler:  <1> . Listens for new connection <2> . Cleans up failed connections <3> . Acknowledges cancellations of commands <4> . Returns result sets, messages, status values to the client
The SQL Server Engine Relational Engine Command Parser
The SQL Server Engine Relational Engine Command Parser (Continued) Functionality Handles language events raised by ODS.  Command Syntax Checker Error Raiser & Identifier Command Translator – Internal Format (Query Tree) Note The only one can access the source of the statement.
The SQL Server Engine Relational Engine Optimizer
The SQL Server Engine Relational Engine Optimizer (Continued) Functionality Takes the Query Tree from the Command Parser and prepared it for execution. Execution Plan Generation <1> . Normalization <2> . Hardware Part:  Memory, CPU, I/O, ETC. <3> . Table Part: Table, Column, Index, ETC.
The SQL Server Engine Relational Engine SQL Manager
The SQL Server Engine Relational Engine SQL Manager (Continued) Functionality Be responsible for everything having to do with managing stored procedures and their plans. Recompilation – Based on changes in the object’s schema Caching of procedure plan management Auto-parameterized Query SELECT * FROM Customer WHERE Customer_ID = ‘1234567’ SELECT * FROM Customer WHERE Customer_ID = @param
The SQL Server Engine Relational Engine Expression Manager
The SQL Server Engine Relational Engine Expression Manager (Continued) Functionality Handles computation, comparison, and data movement. SELECT  @var_Salary =  Salary  * 0.9 FROM Employee WHERE Employee_No = ‘013456’
The SQL Server Engine Relational Engine Query Executor Functionality Runs Execution Plan Interacts with Storage Engine <1> . Modifies Data <2> . Retrieves Data <3> . Manages Transaction <4> . Handles Locking
The SQL Server Engine Storage Engine Functionality Comprises the components needed to actually access and modify data on disk.
The SQL Server Engine Storage Engine Access Methods Manager
The SQL Server Engine Relational Engine Access Methods Manager (Continued) Functionality Sets up and requests scans of data pages / index pages and prepared the OLE (Object Linking and Embedding) DB row sets to return to the Relational Engine. Requester: Access Methods Manager Executer: Row Operations Manager & Index Manager Queries, Updates, and Deletes
The SQL Server Engine Storage Engine Page Manager & Text Manager
The SQL Server Engine Relational Engine Page Manager & Text Manager (Continued) Functionality The Page Manager and Text Manager cooperate to manage a collection of pages as named database. Type of Disk Pages Data Pages Text / Image Pages Index Pages Page Free Space (PFS) Pages Global Allocation Map (GAM) Pages Index Allocation Map (IAM) Pages Bulk Changed Map Pages Differential Changed Map Pages For three kinds of datatypes storage: (1).text (2).ntext (3).image All user data, except for text, ntext, and image datatypes.
The SQL Server Engine Storage Engine Buffer Manager
The SQL Server Engine Relational Engine Buffer Manager  (Continued) Functionality Handles the in-memory version of each physical disk page and provides all other modules access to it. Note When a page is needed for a process, it must exist in memory in the buffer pool. If the page isn’t there, a physical   I  /  O  is performed to get it.
The SQL Server Engine Storage Engine Transaction Manager
The SQL Server Engine Relational Engine Transaction Manager (Continued) Functionality Guarantees the consistency and recoverability of SQL Server databases. Coordinates the following items: <1> . Log Manager <2> . Buffer Manager <3> . Lock Manager  <4> . Recovery Module Note SUSPENDED! Chapter: Transaction Logging And Recovery
The SQL Server Engine Storage Engine Lock Manager
The SQL Server Engine Relational Engine Lock Manager (Continued) Functionality Guards data and the internal resources that make it possible for many users to simultaneously access the database and not be severely affected by others’ uses. Two Separate Locking Systems Locking System  I  –  Fully Shared Data Table Locking System  II  –  Restricted System Data
The SQL Server Engine Relational / Storage Engines & DBMS
Introduction Operating Environment  The SQL Server Engine Memory Management Transaction Logging And Recovery Summary Architectural Overview
Memory Pools What Is Memory Pools ? Why Use It ? Pool Types Buffer Pool 4 ~ 10 MB 1 Buffer = 1 Page (8 KB) Operating System Memory MAX – 4 ~ 10 MB Need Memory Size > 8 KB Memory Management
Buffer Manager In-Memory Pages Access - Hashing Hash Lists Hash Buckets A Hash Bucket is a structure in memory that contains an array of pointers to the buffer page. Hashing Function Hashing is a technique that uniformly maps a key via a hash function across a set of Hash Buckets. Memory Management
Buffer Sweeper - Lazywriter Buffer Pool Management Reference Count Data / Index Pages Expensive Pages Ex: Stored Procedure Plans Free List Memory Management
Introduction Operating Environment  The SQL Server Engine Memory Management Transaction Logging And Recovery Summary Architectural Overview
Corporations of Managers Transaction Manager Buffer Manager Log Manager Lock Manager Recovery Module Transaction Logging And Recovery
Transaction Logging Definition Transaction log is a set of files associated with a database at the time the database is created or altered. LSN Log Sequence Number Transaction Logging And Recovery
Recovery Checkpoint Database-by-database Basis All committed transactions are written to the database. Triggered Conditions Database Owner Issues A Ckeckpoint Command  Log Is Getting Full (more than 70% of capacity) Long Recovery Time Is Estimated Transaction Logging And Recovery
Recovery (Continued) Recovery Algorithm Phase 1: Analysis Phase 2: Redo (rollforward) Phase 3: Undo (rollback) Transaction Logging And Recovery
Recovery (Continued) Transaction Logging And Recovery
Introduction Operating Environment  The SQL Server Engine Memory Management Transaction Logging And Recovery Summary Architectural Overview
Summary What Do You Need to Know Today…  Query Executer
Fundamentals of Database Systems Author: Elmasri / Navathe Publisher: Addison-Wesley Publishing Company Inside of Microsoft SQL Server 2000 Author: Kalen Delaney Publisher: Microsoft Press Reference
Any Question?

SQL Server 2000 Research Series - Architecture Overview

  • 1.
    Technical Integration DepartmentSystem Analysis & Training Group Jerry Yang August 25, 2005 SQL Server 2000 Research Series Architecture Overview
  • 2.
    Introduction Operating Environment The SQL Server Engine Memory Management Transaction Logging And Recovery Summary Agenda
  • 3.
    Introduction Operating Environment The SQL Server Engine Memory Management Transaction Logging And Recovery Summary Architectural Overview
  • 4.
    Introduction What IsIt ? Why Analyze Architecture ? Processing Procedures Performance Issues Hardware Deploy Software Implementation How Should We Proceed ? DBMS Structure SQL Server Components Relationships
  • 5.
    DBMS – DatabaseManagement Systems Introduction Application Programs/Queries Software to Process Queries/Programs Software to Access Stored Data Users/Programmers DATABASE SYSTEM DBMS SOFTWARE Stored Database Definition (Meta-Data) Stored Database
  • 6.
    Introduction Operating Environment The SQL Server Engine Memory Management Transaction Logging And Recovery Summary Architectural Overview
  • 7.
    Service Manager EnterpriseManager Query Analyzer SQL Server Profiler DTS - Data Transformation Services Client Network Utility Operating Environment
  • 8.
    Service Manager EnterpriseManager Query Analyzer SQL Server Profiler DTS - Data Transformation Services Client Network Utility Operating Environment
  • 9.
  • 10.
  • 11.
    Enterprise Manager (Continued)Operating Environment
  • 12.
  • 13.
    Query Analyzer (Continued)Operating Environment
  • 14.
    Introduction Operating Environment The SQL Server Engine Memory Management Transaction Logging And Recovery Summary Architectural Overview
  • 15.
    The SQL ServerEngine SQL Server Architecture Net-Library User Mode Scheduler Relational Engine OLE & Non-OLE DB Communication Storage Engine I/O Manager Win 32 API
  • 16.
    The SQL ServerEngine SQL Server Architecture Net-Library User Mode Scheduler Relational Engine OLE & Non-OLE DB Communication Storage Engine I/O Manager Win 32 API
  • 17.
    The SQL ServerEngine SQL Server Architecture (Continued)
  • 18.
    The SQL ServerEngine Net-Library Functionality An abstraction layer enables SQL Server to read from and write to many different network protocols. Advantage Support many network protocols without having to change the core server code.
  • 19.
    The SQL ServerEngine Net-Library (Continued) Primary Net-Libraries Members OLE DB Provider for SQL Server SQL Server ODBC Driver Super Socket & Shared Memory Inter-computer Connection Local Connection Secondary Net-Libraries Members TCP/IP IPX/SPX ETC.
  • 20.
    The SQL ServerEngine Net-Library (Continued) Operating Environment
  • 21.
    The SQL ServerEngine Net-Library (Continued) Operating Environment
  • 22.
    The SQL ServerEngine Relational Engine Functionality Comprises all the components necessary to parse and optimize any query. Manages the execution of queries as it requests data from the storage engine in terms of OLE DB row sets and then processes the row sets returned.
  • 23.
    The SQL ServerEngine Relational Engine ODS ( O pen D ata S ervices)
  • 24.
    The SQL ServerEngine Relational Engine ODS (Continued) Functionality An interface between server Net-Library and server-based applications. Connection Handler: <1> . Listens for new connection <2> . Cleans up failed connections <3> . Acknowledges cancellations of commands <4> . Returns result sets, messages, status values to the client
  • 25.
    The SQL ServerEngine Relational Engine Command Parser
  • 26.
    The SQL ServerEngine Relational Engine Command Parser (Continued) Functionality Handles language events raised by ODS. Command Syntax Checker Error Raiser & Identifier Command Translator – Internal Format (Query Tree) Note The only one can access the source of the statement.
  • 27.
    The SQL ServerEngine Relational Engine Optimizer
  • 28.
    The SQL ServerEngine Relational Engine Optimizer (Continued) Functionality Takes the Query Tree from the Command Parser and prepared it for execution. Execution Plan Generation <1> . Normalization <2> . Hardware Part: Memory, CPU, I/O, ETC. <3> . Table Part: Table, Column, Index, ETC.
  • 29.
    The SQL ServerEngine Relational Engine SQL Manager
  • 30.
    The SQL ServerEngine Relational Engine SQL Manager (Continued) Functionality Be responsible for everything having to do with managing stored procedures and their plans. Recompilation – Based on changes in the object’s schema Caching of procedure plan management Auto-parameterized Query SELECT * FROM Customer WHERE Customer_ID = ‘1234567’ SELECT * FROM Customer WHERE Customer_ID = @param
  • 31.
    The SQL ServerEngine Relational Engine Expression Manager
  • 32.
    The SQL ServerEngine Relational Engine Expression Manager (Continued) Functionality Handles computation, comparison, and data movement. SELECT @var_Salary = Salary * 0.9 FROM Employee WHERE Employee_No = ‘013456’
  • 33.
    The SQL ServerEngine Relational Engine Query Executor Functionality Runs Execution Plan Interacts with Storage Engine <1> . Modifies Data <2> . Retrieves Data <3> . Manages Transaction <4> . Handles Locking
  • 34.
    The SQL ServerEngine Storage Engine Functionality Comprises the components needed to actually access and modify data on disk.
  • 35.
    The SQL ServerEngine Storage Engine Access Methods Manager
  • 36.
    The SQL ServerEngine Relational Engine Access Methods Manager (Continued) Functionality Sets up and requests scans of data pages / index pages and prepared the OLE (Object Linking and Embedding) DB row sets to return to the Relational Engine. Requester: Access Methods Manager Executer: Row Operations Manager & Index Manager Queries, Updates, and Deletes
  • 37.
    The SQL ServerEngine Storage Engine Page Manager & Text Manager
  • 38.
    The SQL ServerEngine Relational Engine Page Manager & Text Manager (Continued) Functionality The Page Manager and Text Manager cooperate to manage a collection of pages as named database. Type of Disk Pages Data Pages Text / Image Pages Index Pages Page Free Space (PFS) Pages Global Allocation Map (GAM) Pages Index Allocation Map (IAM) Pages Bulk Changed Map Pages Differential Changed Map Pages For three kinds of datatypes storage: (1).text (2).ntext (3).image All user data, except for text, ntext, and image datatypes.
  • 39.
    The SQL ServerEngine Storage Engine Buffer Manager
  • 40.
    The SQL ServerEngine Relational Engine Buffer Manager (Continued) Functionality Handles the in-memory version of each physical disk page and provides all other modules access to it. Note When a page is needed for a process, it must exist in memory in the buffer pool. If the page isn’t there, a physical I / O is performed to get it.
  • 41.
    The SQL ServerEngine Storage Engine Transaction Manager
  • 42.
    The SQL ServerEngine Relational Engine Transaction Manager (Continued) Functionality Guarantees the consistency and recoverability of SQL Server databases. Coordinates the following items: <1> . Log Manager <2> . Buffer Manager <3> . Lock Manager <4> . Recovery Module Note SUSPENDED! Chapter: Transaction Logging And Recovery
  • 43.
    The SQL ServerEngine Storage Engine Lock Manager
  • 44.
    The SQL ServerEngine Relational Engine Lock Manager (Continued) Functionality Guards data and the internal resources that make it possible for many users to simultaneously access the database and not be severely affected by others’ uses. Two Separate Locking Systems Locking System I – Fully Shared Data Table Locking System II – Restricted System Data
  • 45.
    The SQL ServerEngine Relational / Storage Engines & DBMS
  • 46.
    Introduction Operating Environment The SQL Server Engine Memory Management Transaction Logging And Recovery Summary Architectural Overview
  • 47.
    Memory Pools WhatIs Memory Pools ? Why Use It ? Pool Types Buffer Pool 4 ~ 10 MB 1 Buffer = 1 Page (8 KB) Operating System Memory MAX – 4 ~ 10 MB Need Memory Size > 8 KB Memory Management
  • 48.
    Buffer Manager In-MemoryPages Access - Hashing Hash Lists Hash Buckets A Hash Bucket is a structure in memory that contains an array of pointers to the buffer page. Hashing Function Hashing is a technique that uniformly maps a key via a hash function across a set of Hash Buckets. Memory Management
  • 49.
    Buffer Sweeper -Lazywriter Buffer Pool Management Reference Count Data / Index Pages Expensive Pages Ex: Stored Procedure Plans Free List Memory Management
  • 50.
    Introduction Operating Environment The SQL Server Engine Memory Management Transaction Logging And Recovery Summary Architectural Overview
  • 51.
    Corporations of ManagersTransaction Manager Buffer Manager Log Manager Lock Manager Recovery Module Transaction Logging And Recovery
  • 52.
    Transaction Logging DefinitionTransaction log is a set of files associated with a database at the time the database is created or altered. LSN Log Sequence Number Transaction Logging And Recovery
  • 53.
    Recovery Checkpoint Database-by-databaseBasis All committed transactions are written to the database. Triggered Conditions Database Owner Issues A Ckeckpoint Command Log Is Getting Full (more than 70% of capacity) Long Recovery Time Is Estimated Transaction Logging And Recovery
  • 54.
    Recovery (Continued) RecoveryAlgorithm Phase 1: Analysis Phase 2: Redo (rollforward) Phase 3: Undo (rollback) Transaction Logging And Recovery
  • 55.
  • 56.
    Introduction Operating Environment The SQL Server Engine Memory Management Transaction Logging And Recovery Summary Architectural Overview
  • 57.
    Summary What DoYou Need to Know Today… Query Executer
  • 58.
    Fundamentals of DatabaseSystems Author: Elmasri / Navathe Publisher: Addison-Wesley Publishing Company Inside of Microsoft SQL Server 2000 Author: Kalen Delaney Publisher: Microsoft Press Reference
  • 59.