SQL Server 2012 Internal Note_SQL Server Architecture and Configuration
SQL Server 2012 Internal Note_SQL Server Architecture and Configuration
SQL Server Editions
Verify what edition you are running
1 |
|
SQL Tools
- For graphical system, use client tool as SQL Server Management Studio.
- For non-graphical system, use commend line tools as SQLCMD in SQL PowerShell.
SQL Server Metadata
System base tables
System base tables store information about the SQL server, and are used for internal purposes within the Databased Engine.
View names of all system tables as an admin
1 |
|
The only way to see the data in the system base table is to make connection using DAC (dedicated administrator connection).
In SQL Server 2012, three types of system metadata objects are intended for general use: Compatibility Views, Catalog Views, and Dynamic Management Objects.
Compatibility Views
Compatibility views provides the access to a subset of the SQL Server 2000 system tables and are accessible from any database, backward compatibility only (no metadata related to added features)
Catalog Views
SQL Server 2005 introduced a set of catalog views as a general interface to the persisted system metadata.
All catalog views (as well as the Dynamic Management Objects and
compatibility views) are in the sys
schema, which you must
reference by name when you access the objects.
Reference a catalog view called
objects
1 |
|
Columns displayed for catalog views vs compatibility views
1 |
|
There are more columns for SELECT * FROM sys.databases
,
each possible database property has its own column in
sys.databases
.

As a view, sys.databases
can be queried and
filtered:
1 |
|
Inheritance model of catalog views
The base views contain a subset of columns and a superset of rows, and the derived views contain a superset of columns and a subset of rows.
1 |
|
sys.objects
contains all the columns for attributes
common to all types of objects and shows metadata for procedures and
views in addition to that for tables.
sys.tables
contains all the columns in
sys.object
and additional columns that are meaningful for
tables, and shows only rows for tables.

Note that metadata appearing only in the
msdb
database isn’t available through catalog views but is still available in system tables, in the schemadbo
.
See definition of views
1 |
|

Dynamic Management Objects
DMV, Dynamic Management Objects include both views and functions,
provides internal behavior of SQL Server, some of them allow tracking of
detailed resource history, they are all in sys
schema and
have a name that starts with dm_
.
The DMVs aren’t based on real tables stored in database files but are based on internal server structures
Main categories of DMVs
Category | Contains | Example |
---|---|---|
dm_exec_* |
Information about user execution code and connections | sys.dm_exec_sessions |
dm_os_* |
Low-level system information such as memory and scheduling | sys.dm_os_schedulers |
dm_tran_* |
Information about current transactions | sys.dm_tran_locks |
dm_logpool* |
Details about log pools used to manage SQL Server 2012’s log cache | |
dm_io_* |
Keeps track of input/output activity on network and disks | sys.dm_io_virtual_file_stats |
dm_db_* |
Details about databases and database objects such as indexes | sys.dm_db_index_operational_stats |
1 |
|
Other Metadata
Information Schema Views
Information schema views, introduced in SQL Server 7.0, were the original system table-independent view of the SQL Server metadata. The information schema views show only objects compatible with the SQL-92 standard.
System Functions
Property function
Property functions provide individual values for many SQL Server objects as well as for SQL Server databases and the SQL Server instance itself.
Return values are scalars, they can be used as values returned by SELECT statements and as values to populate columns in tables.
1 |
|

Short-cuts for catalog view access
1 |
|
System Stored Procedures
System stored procedures are the original metadata access tool.
Most of the system stored procedures introduced in the very first version of SQL Server are still available.
With the system stored procedures, you have to accept the data that it returns.
Better to use catalog views: 1
2
3
4
5
6-- See databases that the login sue owns
SELECT name FROM sys.databases
WHERE suser_sname(owner_sid) = 'sue';
-- See databases that are in a lower compatibility level
SELECT name FROM sys.databases
WHERE compatibility_level < 150;
Layers Of Metadata
“Other Metadata” refers to system information not contained in system tables.
Preferred interfaces to the system metadata are the catalog views and system functions.

Components of the SQL Server engine

Protocols
Translate client requests for relational engine, translate results for clients.
The SQL Server Network Interface (SNI) protocol layer on both the server and client computers encapsulates the TDS (tabular data stream) packet inside a standard communication protocol, such as TCP/IP or Named Pipes.
SQL Server can support multiple protocols; each client connects to SQL Server with a single protocol.
Available protocols:
- Shared Memory
- The simplest protocol
- Clients using this protocol can connect to only a SQL Server instance running on the same computer
- Use this protocol for trouble-shooting when you suspect that the other protocols are configured incorrectly.
- Named Pipes
- For local area network (LANs)
- A portion of memory is used by one process (output) to pass information (input) to another process (local or remote computer)
- TCP/IP
- Most widely used
- Communicate across interconnected computer networks with diverse hardware architectures and operating systems
- Includes standards for routing network traffic and offers advanced security features.
Query processor (Relational engine)
Determine exactly what your query needs to do and the best way to do it.
Parsing and binding components
Process queries into query trees, raise syntax or name resolution error and identify where the error occurs.
Parsing component:
- Check proper syntax and spelling of keywords
Binding component:
- Resolve object names into unique object ID
After parsing and binding, convert queries into query trees
The Query Optimizer
Takes the query tree, compile entire command batch and optimize optimizable queries, result in an execution plan.
Non-optimizable statements:
- Compile into an internal form
- Such as flow-of-control and Data Definition Language (DDL) commands
Optimizable statements:
- Pass to Query Optimizer
- Such as Data Manipulation Language (DML) statements SELECT, INSERT, UPDATE, DELETE, and MERGE
Steps:
- Normalization
- breaks down a single query into multiple, fine-grained queries
- Optimization
- Determine the most cost-effective execution plan based on internal metrics that include estimated memory requirements, CPU utilization, and number of required I/Os involving sampling data (distribution statistics).
- Avoid exhaustive optimization to ensure the time for optimizing is less than executing any plan.
- Compilation
- Compile normalized tree into execution plan (a data structure)
The execution plan:
- A data structure
- Includes actual commands, steps for checking constraints
- Steps for calling a trigger are not compiled into the execution plan, the existence of a trigger can cause many more steps to be executed.
The query executor
Run the execution plan, dispatch all commands in the plan.
Most commands require interaction with the storage engine to modify or retrieve data and to manage transactions and locking. (Object Linking and Embedding (OLE) DB rowsets involved)
Storage engine
Include components responsible for accessing and managing data in the database.
Access methods
Contains components to open a table, retrieve qualified data, and update data.
Used for any data modification operations that need to modify index entries (SELECT, UPDATE, DELETE)
Row and index operations
Row operation:
- Manipulated on data.
- Retrieves, modifies, and performs operations on individual rows.
- Can handle large object type (LOB)—text, image, or ntext
Index operation:
- Manipulated on index pages
- Maintains and supports searches on B-trees
- An index is structured as a tree, with a root page and intermediate-level and lower level pages