The SQL Server 2022 Workshop
The SQL Server 2022 Workshop
The SQL Server 2022 Workshop
Workshop
Microsoft Azure Data
#sqlserver2022
#azuresql
Goals for this workshop
Module 2 Module 6
Connect SQL Server 2022 to Azure Enhance your application with new
T-SQL capabilities
Module 3
Accelerate performance with Module 7
built-in query intelligence Summary and closing
Module 4
Power your database with
security, scalability, and availability
aka.ms/sql2022workshop
aka.ms/sqlserver2022decks
aka.ms/sqlserver2022series
aka.ms/sqlserver2022demos
Module 1
Azure SQL Server SQL on Linux, Azure Arc- Azure Arc- SQL Server Azure SQL Azure SQL
SQL Edge 2022 containers, k8s enabled SQL enabled SQL on Virtual managed database
Server managed Machines instance
instance
Data
Language Tools Engine Machine Learning
Virtualization
SQL Server 2022
Azure-enabled with continued performance and security innovation
Business continuity Seamless analytics Visibility over your Most secure over the Industry-leading
through Azure over on-prem entire data estate last 10 years1 performance and
operational data availability
+
70
Microsoft Purview 60
A
O L
P QL
gr 2
M er
IB cle
Q
st DB
AN
rv
yS
SA e S
Policies
ra
performance on 1TB3,
H
Se
Po M
L
SQ
3TB4, 10TB5, 30TB6, and
100TB7
SQL Server
2022
Deploying SQL
Server 2022 Windows GUI or
command line
Supported OS
RHEL, Ubuntu,
Same upgrade SLES package managers
options as in
previous releases
Removed
R, Python, and Java packages1
Polybase Hadoop connectivity with
Java
Polybase scale out groups
Machine learning server
Distributed replay2
Deprecated features
Stretch database
Added
Azure extension for SQL Server
Pay As You go Licensing
1
Bring your own runtime packages 2
Will be available for separate
Azure extension for SQL Server
Enterprise
Mission-critical performance and
intelligence for tier 1 databases
Standard
Full featured database with for Feature highlights
mid-tier applications and data • Unlimited cores of CPU
marts
Express • Unlimited memory
Free, entry-level database
• Azure Synapse Link for SQL (multi-
for small web and mobile
Feature highlights threaded snapshot)
apps
• Up to 24 cores of CPU • Link feature for Azure SQL Managed
Feature highlights • Instance
Up to 128 GBs of memory
• Up to 4 cores of CPU • Built-in query intelligence: DOP feedback,
• Azure Synapse Link for SQL
CE Feedback, Memory Grant Feedback
• Up to 1410 MBs of memory • Link feature for Azure SQL Managed
• Contained Availability Group
• Microsoft Purview Policies Instance (basic availability groups)
• AVX 512 extension for batch mode
• Azure AD authentication • Buffer Pool Parallel Scan
• Built-in query intelligence: PSP Optimization, • Backups to S3-compatible object storage
Optimized plan forcing
+ Standard features
• Query store on by default for new databases
+ Express features
• Data Lake Virtualization
• Ledger + Express features
• Timeseries support
Developer
Free to use with all the features of Enterprise Edition specifically for dev/test in non-production environments
Build once and deploy across any SQL Server edition without changing
your app
SQL Server 2022 on Linux, Containers,
Kubernetes
Linux distributions supported
RHEL 8.0 – 8.5
https://aka.mssqllinux
Ubuntu 20.04
https://aka.ms/sqlcontainers
SLELS 15
https://aka.ms/sqlk8s
Marketplace images
Windows and Linux
Dev, Web, Std, and EE Editions
https://aka.ms/sqlazurevm
Which of these is one of the major The Azure extension for SQL Server
categories for SQL Server 2022 provides
features? which of these capabilities?
Demos*
Has SQL Server been hybrid?
SQL Server on Azure Virtual Azure SQL Managed Instance Azure SQL Database
Machines Azure Storage
Replication
Linked Servers
Always-On BACKUP TO URL
Availability Groups
SQL Server 2022 Cloud connected Azure Arc-
enabled
SQL Server
Azure
Microsoft
Active Directory
Purview
Azure Synapse Microsoft Defender
Analytics for SQL
SQL Server
2022
Business continuity through Azure SQL Managed
Instance
Disaster recovery in the cloud with link feature for Azure SQL Managed Instance
Challenge: Difficult to setup and
maintain a DR site Continuously replicate data to the cloud
Online
Use PaaS for managed disaster failover
recovery Offline
failback
Azure
Don’t have an AG? We will build DR in the
one for you with no replica or cloud
clustering required
SQL
Server
Built-in distributed availability 2022
Azure SQL
group (DAG) Managed
Instance
Datacenter Datacenter
1 Log changes 2
Log changes
Log changes forwarded
Primary
Create link
Database 4 Primary
seeding
Secondary
dbm
endpoint
1 dbm
endpoint
BC tier
5
read only read/write read only
6
1 db per (AG) link
Availability Availability
2 Group 1
100 links for target MI
Group 2
Multiple instances across
versions
Online failover to Azure SQL Managed Instance
Single step with SSMS
using the failover wizard
Azure SQL
SQL Server 2022 Managed Instance
Create new
Stop write
link to MI 5 1 workload
(Optional)
Operational
Databases
Landing Zone
Synapse Link
SQL Server 2022
for SQL
Azure
Self-hosted Integration Runtime
Azure SQL
Database
Operational
Databases
SQL Server 2022 database
Analytics
Synapse
Azure
Self-hosted
Integration runtime 3 Synapse workspace
Control channel
Control
Plane Linked
Connection 1
Synapse link stored
procedures 5
Linked Service
database
For LZ
7
Table
snapshot
4
parquet &
schema
Ingestion
6 Log Landing Zone Service 2
changes
2 Multi-factor
authentication
Requires Azure
windows registry
extension
mssql.conf SQL Server 2022
Logins or users without
logins
Linked Servers
Demo
Exercise 2.3
Azure Active Directory
(AAD)
Microsoft Purview integration
Insights, lineage, and governance over your entire data estate
Futures:
More granular scope
New policies
*Preview Self-service access https://aka.ms/
purviewsqlaccesspolicies
Microsoft Purview SQL Server Policy Architecture
Microsoft Purview
Azure
Active Directory
Data
2 DevOps
policies
Azure extension
for SQL Server 1 AAD login
3
4
windows registry
mssql.conf SQL Server 2022 Policy
cache
Demo
Exercises 2.4
Microsoft Purview Access
Policies
Microsoft Defender for Cloud—Databases
Protection
Protect SQLEnable
workloads through security posture ••management
Detect SQL security misconfigurations
and allow timely responses
SQL injection attacks
to threats
Remediate
• Brute-force attacks
1 2 • Unusual data exfiltration 3
Protected • Suspicious access or queries
SQL Workloads
Investigate in
Attacke
Azure
r SecOps
Sentinel
Vulnerabili
Security ty
Alert Assessmen
One-click t Sec admin
enablemen or DBA
t
Microsoft Automatic
Defender
for Cloud response
Link for Managed Instance feature is SQL Server sends changes to Synapse
supported on which SQL Server Link
versions? to what location?
A. Y
ou create a login and then map the login
A. Free inventory of instances and
to a Purview policy
databases
B. Y
ou create a policy in Purview based on
an Azure Active Directory (AAD) account
B. Managed Database Service
C. Y
ou create a role in SQL Server that maps
C. Synapse Link to a Purview policy
D. Y
ou create a AAD login and add it to a
D. Best Practices Assessment
policy role in SQL Server
DBM
endpoint Query Store stats
DBM
endpoint
Primary Read
replica replica
Query Store Query Store
stats stats
Approximate Percentile
Approximate versions for
PERCENTILE_CONT and
PERCENTILE_DISC
1,000,000, rows x
500 bytes per row
Memory Grant
Granted before execution = ~500MB
Allocation during execution
When can memory grants become a problem?
1,000,000, rows x
Memory Grant 500 bytes per row
Granted before execution
= ~500MB
RESOURCE_SEMAPHORE
IO_COMPLETION
What is Memory Grant Feedback (MGF)?
Memory allocated at start of query execution
for operators like hashes and sorts
SQL Server First batch mode only and then row store
2019
Adjust next execution if grant was incorrect
MGF Percentiles and Persistence
MGF Percentiles
MGF Persistence
exec exec
myproc 1 myproc 1
Scan
Seek Seek
Scan
exec exec
myproc 10 myproc 10
How does PSP optimization work?
Parameterized query
Dispatcher plan
Query variant
Query variant Query variant
‘Agents with > 10k to < 1M
‘Agents with < 10k listings’ ‘Agents with >= 1M listings’
listings’
Cached plan: seek + lookup Cached plan: scan + medium Cached plan: scan + large
+ small memory grant memory grant memory grant
CE Versions
• Legacy CE Model < dbcompat 120
• New CE Model >= dbcompat 120
Workarounds
• Don’t change dbcompat (ouch)
• Trace flags
• ALTER DATABASE SCOPED CONFIGURATION SET LEGACY_CARDINALITY_ESTIMATION
• Query hints
An example CE model problem
Analyze = Optimizer
looks for repetitive
Validate = Check
query execution that Apply a query store Persist query hint in
performance has
match CE patterns hint the query store
improved
with incorrect
assumptions
Is parallelism bad?
Parallel efficiency
The lowest DOP to achieve the same query
duration
DOP feedback architecture
SQL query
Query Processor
Provide feedback
DOP feedback
Stable, revert, min
Query Store
DOP feedback details
Eligible queries must have a longer duration and repetitive
Less CPU for DOP query = more CPU for everyone else
A. C
reate a new database with SSMS A. D
ata is skewed and you use ad-hoc
in SQL Server 2022 queries with your application
B. U
se CREATE DATABASE in SQL Server B. S
cenarios where more than one plan in
2022 cache would help with stored procedure
performance
C. R
estore a database backup
from SQL Server 2019 C. S
tored procedure performance using
parameters in filters with >= operators
D. A and B
D. All of the above
E. R
estore a version compatible backup
from Azure SQL Managed Instance
Knowledge check
A. Applies a query hint in plan cache A. ynamically calculating the best setting for
D
sp_configure
B. isables the legacy cardinality estimation
D
model B. he lowest DOP setting for a query to achieve
T
similar duration across executions while
C. riggers a recompile to see if the query gets a
T lowering CPU
different plan
C. MAXDOP setting for the database that lowers
A
D. ynamically change between legacy
D the overall CPU for the system
and new CE model
D. B and C
E. ersist a query store hint for queries that
P
improve in performance
The new Query store is on by default for new
databases, provides hints, works with replicas, and is
a store for new query intelligence
Ledger for SQL Server Buffer pool parallel scan Contained Availability Groups
Strict connected encryption (TDS 8.0) Auto async update stats concurrency Intel QuickAssistTM Technology
backup compression
Security enhancements
Attest to other parties that data Block N Block N-1 Block N-2
integrity has not been compromised
Trusted Database ledger
storage
Automatic digest storage
How to use Ledger for SQL Server
Save digest
“Hands-free” tempdb
XML compression
ADR enhancements
Last valid restore time in
backupset msdb table
In-memory OLTP memory
enhancements
LWW wins auto conflict peer-
to-peer replication
Shrink database concurrency
Contained Availability Groups
Synchronize instance level objects with data
Primary Secondary
Listener
or direct db
context
MyAG MyAG
<db> <db>
Log changes
MyAG_maste MyAG_maste
r r
MyAG_msdb MyAG_msdb
Demo
Exercise 4.2
Contained Availability
Groups
https://aka.ms/sql2022mechanicsupdate
Before Now
VDI Program T-SQL suspend I/O
VSS and SQL Writer Perform your snapshot
T-SQL resume I/O
Preview observations
• Idle systems don’t benefit from QAT in hardware mode
• Hardware mode shines with multiple backup files and heavy CPU workloads
• QAT in software mode will usually outperform the default XPRESS
Purvi’s list
Exercise 4.0
Ledger for SQL Server
Independent verification for Ledger for SQL Server 2022 now eliminates what
SQL Server is done by: type of bottleneck for tempdb:
A. T
he database ledger through system A. PAGEIOLATCH
tables
B. PAGELATCH
B. The Ledger history view
C. Spinlocks
C. Database digests
D. A and B
D. Blockchain data in SQL Server tables
E. Row locks on system pages
Knowledge check
D. A and C
Solution
Access from multiple sources …
without moving data
ODBC NoSQL Relational databases Big Data
• Integrate data with data
virtualization
Excel
Data virtualization and object storage
Directly access any data on object storage
Challenge: I need to access data on modern object storage systems through SQL
SQL Engine
Polybase Services
adls abs
abfs wasb
Install system
polybase feature tables
User external
We support rowgroup tablesIngest, CETAS, join table
and column elimination OPENROWSET
for Parquet and Delta
Partition Switch
SELECT *
CREATE EXTERNAL FROM
<External
TABLE AS SELECT (CETAS) Table>
Archive Table
External Table
Integrating SQL with Microsoft Fabric
Partitioned Table
Partition Switch
Parquet files
SELECT *
CREATE EXTERNAL FROM
<External
TABLE AS SELECT (CETAS) Table>
Archive Table
External Table https://aka.ms/sqlfabricdemo
Using BACKUP/RESTORE with S3 compatible object
storage
REST API
Bonus: 5.3
Notebooks with backup/restore and
S3
Advanced: 5.4
Using minio server with S3
Knowledge check
SQL Server 2022 can now access You can restore a database from AWS
external RDS
data sources through: to SQL Server 2022:
B. E
xport data to parquet files on REST B. False
API data sources from a SELECT
C. A
ccess parquet files on ODBC data
sources
D. A and B
New REST API data sources include Azure
Blob Storage, Azure Data Lake Storage Gen2,
and S3 compatible object store providers
Exercise 6.1
Core T-SQL
Exercise 6.2
Time Series
Exercise 6.3
Bit manipulation functions
Knowledge check
Which important enhancement was
Which T-SQL function can produce JSON added to
formatted data? the STRING_SPLIT function in SQL Server
2022?
A. JSON_OBJECT A. separator
C. JSON_TEXT C. ordinal
What’s new for SQL Server 2022 Read the SQL Server 2022 Blog Series
aka.ms/sqlserver2022docs aka.ms/sqlserver2022blogs
Powershell
sqlcmd
SSRS
• Enhanced Windows Narrator support for the new Windows OS (Operating Systems) and Windows Server
• Security enhancements
• Browser performance improvements with Angular
• Accessibility bug fixes
• Support for SQL Server 2022 instances report server catalog
• Reliability updates
What is a hybrid data platform?