Download presentation
Presentation is loading. Please wait.
Published byAnis Clark Modified over 8 years ago
1
SQL Server Deep Dive Denis Reznik Data Architect at Intapp
2
About me Kiev, Ukraine Data Architect at Intapp Inc. Microsoft MVP Leader of Kyiv SQL Server User Group Co-author of “SQL Server MVP Deep Dives vol. 2” SoftServe IT-Awards judge 2 |
4
SQL Server Network Interface
5
SQL Server Protocols Shared Memory TCP/IP Named Pipes VIA (Deprecated)
6
TDS Endpoints TCP/IP Shared Memory Named Pipes VIA DAC TCP/IP Note: TDS – Tabular Data Stream
7
Query Processing
9
Parser Parse Query Text Check base SQL syntax Check if plan is already in cache Returns ParseTree
10
Algebrizer Check that objects are exist and available in current execution context Define types for every node in ParseTree Returns QueryTree (Logical representation of the query)
11
Optimizer Goal – get the optimal execution plan Optimizer Query Tree Pre-Optimization Search for trivial plan Load statistics (optional) Simplification – syntax transformation
12
Optimizer Phase 0 Exploration – plan alternatives Return Transaction Processing plan Load statistics
13
Optimizer Phase 1 Next set of query rules Returns Quick Plan Estimate parallel plan (executed twice)
14
Optimizer Phase 2 Full optimization Returns Full Plan Indexed views
15
Index (B-Tree) - Seek … … 1.. 1M 1.. 2K 2K+1.. 4K 1M-2K.. 1M 1.. 300 301..800 801..1,5K 1,5K+1..2K SELECT * FROM Users WHERE Id = 523
16
Index (B-Tree) - Scan … … 1.. 1M 1.. 2K 2K+1.. 4K 1M-2K.. 1M 1.. 300 301..800 801..1,5K 1,5K+1..2K SELECT * FROM Users
17
Index (B-Tree) – Range Scan … … 1.. 1M 1.. 2K 2K+1.. 4K 1M-2K.. 1M 1.. 300 301..800 801..1,5K 1,5K+1..2K SELECT * FROM Users WHERE Id BETWEEN 700 AND 1700
18
Statistics 1800 2000 2800 45005400 SELECT * FROM Users WHERE Id BETWEEN 2100 AND 2500
19
Executor Execute query using its Query Plan Ask Storage Engine for data
20
Demo SQL Server, are you kidding me?
21
Storage Engine
22
Buffer Pool Data Cache Database File Access Methods Buffer Manager Select Data
23
Modify Data Buffer Pool Data Cache Database File Access Methods Buffer Manager Transaction Log Log Manager Log Buffer
24
Lock Types - Shared S S S S X X
25
Lock Types - Exclusive X X X X S S
26
Lock Types - Update U U U U S S S S X X
27
Lock Types – Intent locks S S IS
28
S S S S S S … S S 1 2 3 n n = 5000 Table S S if lock can’t be put on table, process will try this every n + 1250 rows 12 Buffer Pool Memory for locks S S > 24% Lock Escalation
29
Demo Use NOLOCK carefully
30
SQL OS
31
Execution model Session Thread Pool Running Suspended Runnable Task(s) SchedulerLogical CPU
32
Demo Worker Threads Starvation
34
@denisreznik denisreznik@live.ru https://www.facebook.com/denis.reznik.5 https://www.linkedin.com/pub/denis-reznik/3/502/234 Thank You!
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.