Last month i was taking interview for the post of DBA. I think, DBA should have knowledge of SQL Server Architecture. I had asked so many questions related to SQL Server Architecture but none of the DBAs had given me proper answer. That is why i want to explore SQL Server Architecture information to new DBAs and Developers.
SQL Server Architecture
- External Protocols
- Database Engine
- SQLOS API
There are four parts of External protocols of SQL Server
- Shared Memory
- Named Pipes
- TCP/IP
- Virtual Interface Adapter(VIA)
We can divide Database engine into two parts
- Storage Engine
- Relational Engine(Query Processor)
The Storage Engine contains some managers to manger storage engine as well as some Utilities and Access Methods
Mangers
- Transaction Services-
- File Manager-
- Buffer Manager-The buffer manager manages disk I/O functions for bringing data and index pages into the data cache so data can be shared among users.
- Lock Manager- To under stand Lock Manager. We need to understand the SQL Server Lock.
Utilities
- Bulk Load
- DBCC
- Backup/ Restore
- ROWS
- INDEXES
- VERSIONS
- PAGES
- ALLOCATIONS
Relation Engine(
Query Processor)In simple words,
It is used to parse, compiles and optimized the Query.
SQL statements are the only commands sent from applications to SQL Server 2005. All the work performed by an instance of SQL Server is the result of accepting, interpreting, and executing SQL statements. The processes by which SQL statements are executed by SQL Server include the following:
- Single SQL Statement Processing
- Stored Procedure and Trigger Execution
- Execution Plan Caching and Reuse
- Parallel Query Processing
Relational Engine(Query Processor) further divided in to five parts.
- Parser, Optimizer-If we execute any query then there are various steps involved in executing the query such as Step1-Lexical phase - Here Code break up will happen at this stage. All the code breaks up as individual tokens. like int a. it will get divided into "int" and "a" Step-2>Syntax analysis- Here my code gets checked for its syntax.Step 3->Semantic phase - Here the semantics will be checked. Step4->Intermediate code generation - Its the fourth stage where an intermediate code will be generated by the compiler its like converting the high level code to machine level code.Step5->Code Optimization - My compiler will holds some optimization technique to optimize the code so that we can achieve effective execution of our code. Step6->Optimized code generation - After code optimization a final code will be generated which can be used to retrieve the data. In sql server this optimized code will be stored and used frequently to fetch the data from the database.Code execution - The optimized code gets executed against the database engine.
- SQL Manager-
- Database Manager
- Query Executer
SQLOS API
We can devide SQLOS API into two parts
- SQLOS
- External Components(Hosting API)
SQL OS
There are seven major components of SQLOS
- Lock Manager
- Synchronization Services
- Thread Scheduler
- Buffer Pool
- Memory Manager
- I/O Manger
- Workers Threads
Buffer Pool-All memory not used by another memory component remains in the buffer pool to be used as a data cache for pages read in from the database files on disk. The buffer manager manages disk I/O functions. When other components require memory, they can request a buffer from the buffer pool. A buffer is a page in memory that's the same size as a data or index page. You can think of it as a page frame that can hold one page from a database. Most of the buffers taken from the buffer pool for other memory components go to other kinds of memory caches, the largest of which is typically the cache for procedure and query plans, which is usually called the procedure cache.
This was very good article
ReplyDeleteAwesome.... Great Effort ...
ReplyDeletewhat is SQLOS API plz clearify ...?
ReplyDelete