SQL Server / Azure SQL
SQL Server is a relational DBMS developed by Microsoft. It runs on Windows and Linux, and the same database engine is also offered as a managed service on Azure (Azure SQL). Where an article's table says "Azure SQL", the cell applies to the SQL Server engine as well. The sandbox on this site uses SQL Server 2022 Developer edition. The SQLOS schedulers and memory regions are covered in Memory and Thread Architecture, and sessions, plan cache, and cursors in Connections, Cursors, and Plan Cache.
Key Specs
| Item | Value |
|---|---|
| Storage unit | 8KB page (fixed). Eight pages make one extent (64KB) |
| Files | Data files (.mdf, .ndf), transaction log file (.ldf) |
| Table storage | Heap or clustered index. Creating a primary key makes it clustered by default |
| What a secondary index points to | The clustering key for a clustered table, the row address (RID) for a heap |
| Maximum row size | 8,060 bytes of in-row data. Variable-length columns beyond that go to row overflow |
| Buffer pool | Buffer pool, capped by max server memory |
| Large value handling | varchar(max), nvarchar(max), varbinary(max): LOB pages |
| Concurrency control | Locking by default. With snapshot isolation or READ_COMMITTED_SNAPSHOT enabled, row versions (version store) |
| Default isolation level | Read Committed. In Azure SQL Database, READ_COMMITTED_SNAPSHOT is on by default |
| Operating system cache | Bypassed. Data and log files are read and written unbuffered |
Product Lineup
| Name | Form | Traits |
|---|---|---|
| SQL Server | Self-installed | Enterprise, Standard, Express (free, 10GB per database), Developer (free, development and test only) |
| Azure SQL Database | Per-database PaaS | Always the latest engine with no version concept. Memory and CPU are set by service tier and vCore count |
| Azure SQL Managed Instance | Per-instance PaaS | Supports most instance features, such as SQL Server Agent and cross-database queries |
| SQL Server on Azure VM | IaaS | SQL Server installed directly on a virtual machine |
Old Values and the Version Store
In the default configuration, UPDATE changes the value in place and leaves the old value only in the transaction log. Readers wait on locks. When you turn on ALTER DATABASE ... SET READ_COMMITTED_SNAPSHOT ON or ALLOW_SNAPSHOT_ISOLATION ON, the old row version is copied to the version store in tempdb, and readers read that version without waiting. From 2019, with Accelerated Database Recovery (ADR) turned on, versions are kept in a persistent version store (PVS) inside the user database.
Configuration and Checks
SELECT @@VERSION;
SELECT SERVERPROPERTY('Edition') AS edition, SERVERPROPERTY('EngineEdition') AS engine_edition;
SELECT name, is_read_committed_snapshot_on, snapshot_isolation_state_desc FROM sys.databases;
SELECT name, type_desc, size * 8 / 1024 AS size_mb FROM sys.database_files;
Comparison with Other DBMSs
- You can choose a heap or a clustered index for each table. PostgreSQL uses only heaps, and MySQL (InnoDB) uses only clustered tables.
- Most DDL can be rolled back inside a transaction.
- It is the only DBMS whose page size cannot be changed (fixed at 8KB).
In the Articles
- 1.4 When a Record Is Updated
- 1.6 Buffer Pool Management Rules by Database
- 1.8 Differences Between DBMSs
NOTE Limits by edition and Azure defaults can vary with the version and service tier.
Related pages
- SQL Server Memory and Thread Structure
- SQL Server Connections, Cursors, and Plan Cache
- DBMS Architecture at a Glance
- SQL Server Buffer Pool
- SQL Server LOB and Row Overflow
- SQL Server Transaction Log
- PAGE_VERIFY
- Delayed Durability
- SQL Server Locks and Lock Escalation
- RCSI and Snapshot Isolation
- Operating system cache and direct I/O
- PostgreSQL
- MySQL (InnoDB)
- Oracle Database