enhancements that will make your sql database engine roar part 1 · 2019. 3. 8. · allocation...

33

Upload: others

Post on 04-Feb-2021

8 views

Category:

Documents


0 download

TRANSCRIPT

  • Pedro [email protected]@microsoft.com

    Senior Program Manager

    Focused on SQL Server Relational Engine

    7 years at Microsoft

  • It just works - performance and

    scale in SQL Server 2016 database

    engine and what is being added to

    in-market versions

    Show new diagnostics

    improvements for SQL Server

    engine

    Learn how to use the new

    diagnostics to

    troubleshoot common

    performance issues

    Use the new features to get a highly

    scalable out-of-box performance

  • SQL Server Tiger Team

  • • Trace Flags

    • Configuration Options

    Too many knobs

    • Database integrity checks

    • Partition changes

    • Schema changes

    Downtime for database maintenance

    • Insufficient or unstructured diagnostics

    Repeated data collection

  • Perf and Scale

    • Tempdb

    • Query

    Compilation

    • SOS_RW Lock

    • Memory

    allocation

    • Auto Soft NUMA

    • Large systems

    • Multiple Log

    Writers

    Availability

    • Schema changes

    • Partition

    management

    • Always On

    Diagnostics

    • Integrity Checks

    • Query Progress

    • Query Execution

    • Always On

    • Backup and

    Restore

    • Recovery

    • SQLDumper

    • xEvents

    • Showplan

  • • PFS, GAM, SGAM

    • Solution: Trace flags (1117,1118) and Multiple

    files

    Allocation latch contention

    • High create/drop workloads

    • LATCH_EX waits on underlying system tables

    • Solution: Rewrite t-sql code to reduce temp

    tables

    Metadata latch contention

  • Trace flags removed

    • 1117 and 1118 behavior will be enabled by default for tempdb

    Improved scanning algorithms

    • Reduces metadata contention

    • Optimistic locking of system tables under shared latch

    New defaults*

    • Setup experience

    • Size and auto growth

  • Trace flags removed

    • New extensions in ALTER DATABASE commands

    1118

    • ALTER DATABASE SET MIXED_PAGE_ALLOCATION { ON | OFF }

    • Default value of the MIXED_PAGE_ALLOCATION is OFF

    • New column in sys.databases (is_mixed_page_allocation)

    1117

    • ALTER DATABASE MODIFY FILEGROUP {

    AUTOGROW_ALL_FILES | AUTOGROW_SINGLE_FILE }

    • Default value is AUTOGROW_SINGLE_FILE for all files in all filegroups

    • New column in sys.filegroups (is_autogrow_all_files)

  • Database TF 1117 TF 1118

    TempDB Not required (default) Not required (default)

    User

    Databases

    Default behavior will grow single

    file.

    Use ALTER DATABASE

    MODIFY FILEGROUP [PRIMARY]

    AUTOGROW_ALL_FILES to grow

    all files in the filegroup.

    Not required (default).

    Use ALTER DATABASE

    SET

    MIXED_PAGE_ALLOCATION

    ON to go back to using mixed

    extents

    System

    DatabasesN.A.

    Allocations use mixed page

    extents, cannot be changed.

  • SQL Server Tiger Team

    Instant File Initialization

    requires permission

    SE_MANAGE_VOLUME

  • SQL Server Tiger Team

    Pa

    ge

    Pa

    ge

    Pa

    ge

    Pa

    ge

    Pa

    ge

    Pa

    ge

    Pa

    ge

    Pa

    ge

    Pa

    ge

    Pa

    ge

    Pa

    ge

    Pa

    ge

    Aisle

    1 2 3 4 5 6 7 8

    Contention when

    many CPUs try to

    use the FSB…

  • SQL Server Tiger Team

    Pa

    ge

    Pa

    ge

    Pa

    ge

    Pa

    ge

    Pa

    ge

    Pa

    ge

    Aisle 1Pa

    ge

    Pa

    ge

    Pa

    ge

    Pa

    ge

    Pa

    ge

    Pa

    ge

    Aisle 2Pa

    ge

    Pa

    ge

    Pa

    ge

    Pa

    ge

    Pa

    ge

    Pa

    ge

    Aisle 3Pa

    ge

    Pa

    ge

    Pa

    ge

    Pa

    ge

    Pa

    ge

    Pa

    ge

    Aisle 4

    1 2 3 4 5 6 7 8Bypass the single FSB bottleneck +

    Lazy Writer per Node + Checkpoint per Node

  • SQL Server Tiger Team

  • SQL Server Tiger Team

    Memory

    Object

    CMEMTHREAD mutex

    protects a memory

    object Memory

    Object

    More cores increases

    contention

    Increased wait times

    Severe performance

    degradation

  • SQL Server Tiger Team

    MO MO MO

    MO MO MO

    MO MO MO

    MO MO MO

    Node 2

    MO MO MO

    MO MO MO

    MO MO MO

    MO MO MO

    Node 1

    Memory

    Object

    Memory

    Object

    Node 1

    Memory

    Object

    Node 2

    SQL Server 2016 and 2014 SP2

  • SQL Server Tiger Team

  • SQL Server Tiger Team

    • CREATE TABLE dbo.doc_exy (C1 INT, C2 varchar(50) NULL, C3 decimal (4,2)); --Change TypeALTER TABLE dbo.doc_exyALTER COLUMN C1 DECIMAL (5, 2) WITH (ONLINE = ON)--Change collationALTER TABLE dbo.doc_exyALTER COLUMN C2 varchar(50) COLLATE Latin1_General_BIN WITH (ONLINE = ON)-- Increase the scale and precision of

    the decimal column. ALTER TABLE dbo.doc_exy ALTER COLUMN C3 decimal (10,4) WITH (ONLINE = ON)--Others (Nullability, Sparseness)

    TRUNCATE TABLE PartitionTable1 WITH (PARTITIONS (6 TO 8));

  • SQL Server Tiger Team

    • sys.

    1 Big Gateway 5 *

    Gateway SQL Server 2014 and older

  • SQL Server Tiger Team

    7x improvement

  • SQL Server Tiger Team

  • SQL Server Tiger Team

  • SQL Server Tiger Team

  • SQL Server Tiger Team

  • SQL Server Tiger Team

  • SQL Server Tiger Team

  • SQL Server Tiger Team

  • SQL Server Tiger Team