05. Configuring the Instance

sp_configure

If configuration value does not equal run value, either restart or reconfiguration is needed.

exec sp_configure $parm $val
RECONFIGURE [WITH OVERRIDE]
exec sp_configure 'show advanced options',1

SELECT * FROM sys.configurations
    WHERE is_dynamic = 1 /* needs reconfiguration */
    WHERE is_dynamic = 0 /* needs restart */

Processor Affinity

SSIS is incorporated into the DB engine. When SSIS (SQLServerInt.Serv) run, they run in a separate process and are not restricted by processor affinity.

Align processors on same NUMA node.

Do not use processor affinity with VM oversubscription because NUMA boundaries are not restricted.

For active/active failover, processor affinity should be so as to guarantee sonsistent performance in the event of a failover.

Processor affinity avoids overhead associated with moving threads between processors at the operating system level.

Afinity I/O mask:

Do align Affinity I/O Mask and processor mask onto the same core.

Bitmap in signed 32-bit integer or 64-bit.

EXEC sp_configure 'affinity mask',15
RECONFIGURE

For 256 logical processors (max), use:

ALTER SERVER CONFIGURATION SET PROCESS AFFINITY CPU=4 TO 3
ALTER SERVER CONFIGURATION SET PROCESS AFFINITY NUMANODE=0,14

MAXDOP

MAXDOP will set the maximum number of cores that will be made available to each individual execution of a query.

CXPACKET want type

MAXDOP = min(8, #cores, #cores in NUMA node)
0 = all visible cores
EXEC sys.sp_configure 'max degree of parallelism',8
RECONFIGURE

LMAXDOP increases parallel plan threshold. Default is 5 seconds. This is ignored if MAXDOP = 1.

EXEC sys.sp_configure 'cost threshold for parallelim',10
RECONFIGURE

Min and Max Server Memory

Usually MIN = MAX (avoids overhead of dynamically allocation memory)

Benefit with multiple instances

min (RAM - 2GB, (RAM / 8) * 7)

Trace Flags

DBCC TRACEON(x,-1) /* Global */
DBCC TRACEON(x) /* Current process */
DBCC TRACESTATUS
DBCC TRACEOFF(x,-1) /* Global */
DBCC TRACEOFF(x) /* Current process */

These settings are transient - lost on restart. Persist through -T startup parm

Ports

Named instance can use dynamic ports - no recommended because of difficulty with firewalls.

Service Port Protocol
Browser 1433 TCP
Instance over TCP/IP 1433 TCP
Instance over Named Pipes 445 TCP
DAC (Dedicated Admin Console) 1434 TCP
Service Broker 4022 TCP
Always on Availability Group 5022 TCP
Merge replication with Web Sync 21 TCP
  80 TCP
  137 UDP
  138 UDP
  139 TCP
  445 TCP
T-SQL Debugger 135 TCP

System Databases

sys.dm_db_session_space_usage
sys.dm_db_task_space_usage
sys.dm_db_file_space_usage (Temp database data only available in TempDB context)
sys.dm_tran_version_store
sys.dm_tran_active_snapshot_database_transactions

One (1) TempDB file per core. Min 2, Max 8. More is needed if there is GAM/SGAM contention:

2019: Memory optimized TempDB Metadata cannot access mem-opt objects across multiple databases.

Buffer Pool Extension

WAL Write ahead Logging

Buffer Pool Extension designed for SSD.

Hybrid Buffer Pool

On memory bus SSD. Direct access. Allocation Unit 2MB.

Transaction logs can be stored here.

Enlightment - memory mapped I/O only used for clean pages

Enable trace flag 809 (Windows) or 3979 (Linux).