SlideShare a Scribd company logo
1 of 38
Тема доклада
Тема доклада
Тема доклада
KYIV 2019
When SQL Server Best Practices do not work
.NET CONFERENCE #1 IN UKRAINE
Тема доклада
Тема доклада
Тема доклада
.NET LEVEL UP
About Me
.NET CONFERENCE #1 IN UKRAINE KYIV 2019
• Denis Reznik
• Kyiv, Ukraine
• Data Architect at Intapp, Inc.
• Microsoft Data Platform MVP
• Co-Founder of Ukrainian Data Community Kyiv
• PASS Regional Mentor, CEE
• Co-author of “SQL Server MVP Deep Dives 2”
Тема доклада
Тема доклада
Тема доклада
.NET LEVEL UP
Agenda
.NET CONFERENCE #1 IN UKRAINE KYIV 2019
• Database Should Be Normalized
• Each Table Should Have a Clustered Index
• Column Datatypes Should Be as Small as Possible
• Cost Threshold for Parallelism Should be Higher Than Default
• Max Degree of Parallelism Should Be Set to Best Practices Value
• Bonus: NOLOCK Side Effect
Тема доклада
Тема доклада
Тема доклада
KYIV 2019
Database Should Be Normalized
.NET CONFERENCE #1 IN UKRAINE
.NET LEVEL UP
First Normal Form (1NF)
.NET CONFERENCE #1 IN UKRAINE KYIV 2019
Company User Phone Phone Type
Microsoft John Dow +380969785732 NULL
Microsoft John Dow +32345409123 NULL
Microsoft Larry McGregor +45678904692 NULL
Oracle Corp. John Snow +380988958371 NULL
Amazon Jack Snack +23348902385 Home
Amazon Jack Snack +69058763287 Work
Each cell contains an atomic value
Company User Phone
Microsoft John Dow Tel1: +380969785732, Tel2: +32345409123
Microsoft Larry McGregor Tel: +45678904692
Oracle Corp. John Snow +380988958371
Amazon Jack Snack Home: +23348902385 Work: +69058763287
UsersUsers
Тема доклада
Тема доклада
Тема доклада
KYIV 2019
Database Should Be Normalized
.NET CONFERENCE #1 IN UKRAINE
Demo
Тема доклада
Тема доклада
Тема доклада
KYIV 2019
Database Should Be Normalized
Conclusion
.NET CONFERENCE #1 IN UKRAINE
• Normalize when in makes sense
• Denormalize when it makes sense
• Do not know what to do? Normalize.
• Do not afraid of Denormalization.
Тема доклада
Тема доклада
Тема доклада
KYIV 2019
Each Table Should Have a Clustered Index
.NET CONFERENCE #1 IN UKRAINE
Heap
1 .. 100
100 .. 1k
5K .. 6K
1K .. 5K
6K .. 7K
15K .. 21K
12K .. 15K
10K .. 11K
21K .. 22K
22K .. 41K
9K .. 10K
41K .. 51K
7K .. 8K
8K .. 9K
71K .. 1M
51K .. 71K
1M .. 2M
2M .. 3M
Clustered Index
…
…
1 .. 1M
1 .. 2K 2K+1 .. 4K 1M-2K .. 1M
1 .. 300 301 .. 800 801 .. 1,5K 1,5K+1 .. 2K
Index 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
Non-Clustered Index
…
A .. Z
A .. C C .. K X .. Z
…
1 .. 1M
1 .. 2K 2K+1 .. 4K 1M-2K .. 1M
SELECT * FROM Users
WHERE Name = 'John Dow'
1 .. 2K 2K .. 4K 1M-2K .. 1M
Clustered Index
(Id)
Non-Clustered Index
(Name)
Heap
Тема доклада
Тема доклада
Тема доклада
KYIV 2019
Each Table Should Have a Clustered Index
.NET CONFERENCE #1 IN UKRAINE
Demo
Тема доклада
Тема доклада
Тема доклада
KYIV 2019
Each Table Should Have a Clustered Index
Conclusion
.NET CONFERENCE #1 IN UKRAINE
• Do not afraid Heaps
• RID Lookup requires less IO than Key Lookup
• Consider Heaps for:
• High Key Lookup workloads
• Big tables with high insert rate
Тема доклада
Тема доклада
Тема доклада
KYIV 2019
Column Datatypes Should Be as Small as Possible
.NET CONFERENCE #1 IN UKRAINE
Тема доклада
Тема доклада
Тема доклада
.NET LEVEL UP
Possible Size Reduction
.NET CONFERENCE #1 IN UKRAINE KYIV 2019
• int (4 Bytes) -> smallint (2B) -> tinyint (1B) -> bit (up to 1 Byte)
• float -> decimal
• datetime -> smalldatetime(?) -> datetime2
• nchar (2 Bytes per character) -> char (1 Byte per character)
• nvarchar (2 Bytes per character) -> varchar (1 Byte per character)
Тема доклада
Тема доклада
Тема доклада
KYIV 2019
Column Datatypes Should Be as Small as Possible
.NET CONFERENCE #1 IN UKRAINE
Demo
.NET LEVEL UP
Data Type Precedence
.NET CONFERENCE #1 IN UKRAINE KYIV 2019
1. user-defined data types (highest)
2. sql_variant
3. xml
4. datetimeoffset
5. datetime2
6. datetime
7. smalldatetime
8. date
9. time
10. float
11. real
12. decimal
13. money
14. smallmoney
15. bigint
16. int
17. smallint
18. tinyint
19. bit
Тема доклада
Тема доклада
Тема доклада
KYIV 2019
Column Datatypes Should Be as Small as Possible
Conclusion
.NET CONFERENCE #1 IN UKRAINE
• Works for almost all datatypes
• Use correct datatypes for each column
• Prefer (by default) nvarchar over varchar
Тема доклада
Тема доклада
Тема доклада
KYIV 2019
Cost Threshold for Parallelism Should be Higher Than Default
.NET CONFERENCE #1 IN UKRAINE
• Goal – get the optimal execution plan
• “Optimal” = Plan with the smallest cost
• Cost = sum_of_all_operators_costs(I/O + CPU + memory_consumption)
Optimizer
Query Tree
Pre-Optimization
Search for trivial plan
Load statistics (simple)
Simplification – syntax transformation
Optimization
Optimizer Phase 0
Load Statistics
Exploration – Plan Alternatives
Estimated cost < 0.2
Return Transaction Processing Plan
Optimization
Query Plan Alternatives SELECT * FROM Users u
INNER JOIN Posts p
ON u.Id = p.OwnerUserId
WHERE u.DisplayName = 'John
Snow'
Users
Posts
Posts
Users
Query Plan Alternatives
• 1 Table – 1 option
• 2 Tables – 2 options
• 3 Tables – 6 options
• 4 Tables – 24 options
• …
• 10 Tables – 3628800 options
• 1 Table – 1!
• 2 Tables – 2!
• 3 Tables – 3!
• 4 Tables – 4!
• …
• 10 Tables – 10!
Dynamic Programming
• JOIN(A,B,C,D)
• JOIN(A,B,D,C)
• JOIN(A,C,D,B)
• JOIN(A,D,B,C)
• JOIN(A,D,C,B)
• JOIN(B,A,C,D)
• JOIN(B,A,D,C)
• …
• O(N!)
• JOIN(A,B,C,D)
• A – Optimal Access Path
• B – Optimal Access Path
• … pruning
• (A,B) – Optimal Access Path
• … pruning
• (A,B),(C)
• … pruning
• O(𝑁2 𝑛−1
)
Optimizer Phase 1
Next set of query rules
Estimate parallel plan (estimation processed twice)
• Max Degree of Parallelism
• Cost Threshold for Parallelism
Estimated cost < 1.0
Returns Quick Plan
Optimization
Тема доклада
Тема доклада
Тема доклада
KYIV 2019
Cost Threshold for Parallelism Should be Higher Than Default
.NET CONFERENCE #1 IN UKRAINE
Demo
Тема доклада
Тема доклада
Тема доклада
KYIV 2019
Cost Threshold for Parallelism Should be Higher Than Default
Conclusion
.NET CONFERENCE #1 IN UKRAINE
• Good to set it higher on a fresh server
• Bad to set in higher for the working system
• Setting it for a working system requires validation
• Validate it for top 5-20 CPU intensive queries
Тема доклада
Тема доклада
Тема доклада
KYIV 2019
Max Degree of Parallelism Should Be Set to Best Practices Value
.NET CONFERENCE #1 IN UKRAINE
Parallel Query Execution
• Amdal’s Law
Thread 1
Thread 2
Thread 3
Thread 4
1s2s
Optimizer Phase 2 (Last Phase)
Full Set of Optimization Rules
Indexed views
Returns Full Query Plan
• All planned checks were done
• Good Enough Plan was Found
• Timeout
• Not Enough Memory
Optimization
Тема доклада
Тема доклада
Тема доклада
KYIV 2019
Max Degree of Parallelism Should Be Set to Best Practices Value
.NET CONFERENCE #1 IN UKRAINE
Demo
Тема доклада
Тема доклада
Тема доклада
KYIV 2019
Max Degree of Parallelism Should Be Set to Best Practices Value
Conclusion
.NET CONFERENCE #1 IN UKRAINE
• High DOP usually force query to waste CPU
• But not in every situation
• MAXDOP 1 gives the Optimizer a bit more time
Тема доклада
Тема доклада
Тема доклада
KYIV 2019
Bonus: NOLOCK Side Effect
.NET CONFERENCE #1 IN UKRAINE
Тема доклада
Тема доклада
Тема доклада
KYIV 2019
Bonus: NOLOCK Side Effect
.NET CONFERENCE #1 IN UKRAINE
Demo
Extent N
Allocation Order Scan
…
1 .. 1M
1 .. 2K 2K+1 .. 4K 1M-2K .. 1M
Clustered Index (Id)
Extent 1
Index Allocation Map (IAM)
Extent 1
Extent 2
Extent N
Тема доклада
Тема доклада
Тема доклада
.NET LEVEL UP
Summary
.NET CONFERENCE #1 IN UKRAINE KYIV 2019
• Database Should Be Normalized
• Each Table Should Have a Clustered Index
• Column Datatypes Should Be as Small as Possible
• Cost Threshold for Parallelism Should be Higher Than Default
• Max Degree of Parallelism Should Be Set to Best Practices Value
• Add “If it does make sense” after each of the statements above
• Bonus: NOLOCK and Cursor Threshold
Тема доклада
Тема доклада
Тема доклада
KYIV 2019
When SQL Server Best Practices do not work
.NET CONFERENCE #1 IN UKRAINE
Denis Reznik
Twitter: @denisreznik
Email: denisreznik@gmail.com
Blog: http://reznik.uneta.com.ua
Facebook: https://www.facebook.com/denis.reznik.5
LinkedIn: http://ua.linkedin.com/pub/denis-reznik/3/502/234

More Related Content

Similar to .NET Fest 2019. Денис Резник. Когда SQL Server Best Practices не работают

DotNext 2017 in Moscow - .NET Core Networking stack and Performance -- Karel ...
DotNext 2017 in Moscow - .NET Core Networking stack and Performance -- Karel ...DotNext 2017 in Moscow - .NET Core Networking stack and Performance -- Karel ...
DotNext 2017 in Moscow - .NET Core Networking stack and Performance -- Karel ...Karel Zikmund
 
SE2016 BigData Denis Reznik "Data driven future"
SE2016 BigData Denis Reznik "Data driven future"SE2016 BigData Denis Reznik "Data driven future"
SE2016 BigData Denis Reznik "Data driven future"Inhacking
 
Apache Carbondata: An Indexed Columnar File Format for Interactive Query with...
Apache Carbondata: An Indexed Columnar File Format for Interactive Query with...Apache Carbondata: An Indexed Columnar File Format for Interactive Query with...
Apache Carbondata: An Indexed Columnar File Format for Interactive Query with...Spark Summit
 
.NET Fest 2019. Сергей Медведев. How serverless makes Integration TDD a reali...
.NET Fest 2019. Сергей Медведев. How serverless makes Integration TDD a reali....NET Fest 2019. Сергей Медведев. How serverless makes Integration TDD a reali...
.NET Fest 2019. Сергей Медведев. How serverless makes Integration TDD a reali...NETFest
 
.NET Core Summer event 2019 in Brno, CZ - .NET Core Networking stack and perf...
.NET Core Summer event 2019 in Brno, CZ - .NET Core Networking stack and perf....NET Core Summer event 2019 in Brno, CZ - .NET Core Networking stack and perf...
.NET Core Summer event 2019 in Brno, CZ - .NET Core Networking stack and perf...Karel Zikmund
 
Scale by the Bay 2019 Reprogramming the Programmer
Scale by the Bay 2019 Reprogramming the ProgrammerScale by the Bay 2019 Reprogramming the Programmer
Scale by the Bay 2019 Reprogramming the ProgrammerPaul Cleary
 
An early look at the LDBC Social Network Benchmark's Business Intelligence wo...
An early look at the LDBC Social Network Benchmark's Business Intelligence wo...An early look at the LDBC Social Network Benchmark's Business Intelligence wo...
An early look at the LDBC Social Network Benchmark's Business Intelligence wo...Gábor Szárnyas
 
Open Source North - MongoDB Advanced Schema Design Patterns
Open Source North - MongoDB Advanced Schema Design PatternsOpen Source North - MongoDB Advanced Schema Design Patterns
Open Source North - MongoDB Advanced Schema Design PatternsMatthew Kalan
 
.NET Fest 2019. Оля Гавриш. .NET Core 3.0 и будущее .NET
.NET Fest 2019. Оля Гавриш. .NET Core 3.0 и будущее .NET.NET Fest 2019. Оля Гавриш. .NET Core 3.0 и будущее .NET
.NET Fest 2019. Оля Гавриш. .NET Core 3.0 и будущее .NETNETFest
 
Trivadis TechEvent 2017 Querying distributed data with SQL and Apache Drill b...
Trivadis TechEvent 2017 Querying distributed data with SQL and Apache Drill b...Trivadis TechEvent 2017 Querying distributed data with SQL and Apache Drill b...
Trivadis TechEvent 2017 Querying distributed data with SQL and Apache Drill b...Trivadis
 
N1QL: What's new in Couchbase 5.0
N1QL: What's new in Couchbase 5.0N1QL: What's new in Couchbase 5.0
N1QL: What's new in Couchbase 5.0Keshav Murthy
 
Moving Toward Deep Learning Algorithms on HPCC Systems
Moving Toward Deep Learning Algorithms on HPCC SystemsMoving Toward Deep Learning Algorithms on HPCC Systems
Moving Toward Deep Learning Algorithms on HPCC SystemsHPCC Systems
 
ScyllaDB V Developer Deep Dive Series: Resiliency and Strong Consistency via ...
ScyllaDB V Developer Deep Dive Series: Resiliency and Strong Consistency via ...ScyllaDB V Developer Deep Dive Series: Resiliency and Strong Consistency via ...
ScyllaDB V Developer Deep Dive Series: Resiliency and Strong Consistency via ...ScyllaDB
 
GraphTour - Neo4j Database Overview
GraphTour - Neo4j Database OverviewGraphTour - Neo4j Database Overview
GraphTour - Neo4j Database OverviewNeo4j
 
Automated Slow Query Analysis: Dex the Index Robot
Automated Slow Query Analysis: Dex the Index RobotAutomated Slow Query Analysis: Dex the Index Robot
Automated Slow Query Analysis: Dex the Index RobotMongoDB
 
Conceptos básicos. Seminario web 1: Introducción a NoSQL
Conceptos básicos. Seminario web 1: Introducción a NoSQLConceptos básicos. Seminario web 1: Introducción a NoSQL
Conceptos básicos. Seminario web 1: Introducción a NoSQLMongoDB
 
Rockwell Automation TechED 2017 - AP05 - Enbridge Energy
Rockwell Automation TechED 2017 - AP05 - Enbridge EnergyRockwell Automation TechED 2017 - AP05 - Enbridge Energy
Rockwell Automation TechED 2017 - AP05 - Enbridge EnergyRockwell Automation
 

Similar to .NET Fest 2019. Денис Резник. Когда SQL Server Best Practices не работают (20)

DotNext 2017 in Moscow - .NET Core Networking stack and Performance -- Karel ...
DotNext 2017 in Moscow - .NET Core Networking stack and Performance -- Karel ...DotNext 2017 in Moscow - .NET Core Networking stack and Performance -- Karel ...
DotNext 2017 in Moscow - .NET Core Networking stack and Performance -- Karel ...
 
Denis Reznik Data driven future
Denis Reznik Data driven futureDenis Reznik Data driven future
Denis Reznik Data driven future
 
SE2016 BigData Denis Reznik "Data driven future"
SE2016 BigData Denis Reznik "Data driven future"SE2016 BigData Denis Reznik "Data driven future"
SE2016 BigData Denis Reznik "Data driven future"
 
Apache Carbondata: An Indexed Columnar File Format for Interactive Query with...
Apache Carbondata: An Indexed Columnar File Format for Interactive Query with...Apache Carbondata: An Indexed Columnar File Format for Interactive Query with...
Apache Carbondata: An Indexed Columnar File Format for Interactive Query with...
 
.NET Fest 2019. Сергей Медведев. How serverless makes Integration TDD a reali...
.NET Fest 2019. Сергей Медведев. How serverless makes Integration TDD a reali....NET Fest 2019. Сергей Медведев. How serverless makes Integration TDD a reali...
.NET Fest 2019. Сергей Медведев. How serverless makes Integration TDD a reali...
 
.NET Core Summer event 2019 in Brno, CZ - .NET Core Networking stack and perf...
.NET Core Summer event 2019 in Brno, CZ - .NET Core Networking stack and perf....NET Core Summer event 2019 in Brno, CZ - .NET Core Networking stack and perf...
.NET Core Summer event 2019 in Brno, CZ - .NET Core Networking stack and perf...
 
Scale by the Bay 2019 Reprogramming the Programmer
Scale by the Bay 2019 Reprogramming the ProgrammerScale by the Bay 2019 Reprogramming the Programmer
Scale by the Bay 2019 Reprogramming the Programmer
 
An early look at the LDBC Social Network Benchmark's Business Intelligence wo...
An early look at the LDBC Social Network Benchmark's Business Intelligence wo...An early look at the LDBC Social Network Benchmark's Business Intelligence wo...
An early look at the LDBC Social Network Benchmark's Business Intelligence wo...
 
Open Source North - MongoDB Advanced Schema Design Patterns
Open Source North - MongoDB Advanced Schema Design PatternsOpen Source North - MongoDB Advanced Schema Design Patterns
Open Source North - MongoDB Advanced Schema Design Patterns
 
.NET Fest 2019. Оля Гавриш. .NET Core 3.0 и будущее .NET
.NET Fest 2019. Оля Гавриш. .NET Core 3.0 и будущее .NET.NET Fest 2019. Оля Гавриш. .NET Core 3.0 и будущее .NET
.NET Fest 2019. Оля Гавриш. .NET Core 3.0 и будущее .NET
 
Trivadis TechEvent 2017 Querying distributed data with SQL and Apache Drill b...
Trivadis TechEvent 2017 Querying distributed data with SQL and Apache Drill b...Trivadis TechEvent 2017 Querying distributed data with SQL and Apache Drill b...
Trivadis TechEvent 2017 Querying distributed data with SQL and Apache Drill b...
 
N1QL: What's new in Couchbase 5.0
N1QL: What's new in Couchbase 5.0N1QL: What's new in Couchbase 5.0
N1QL: What's new in Couchbase 5.0
 
Moving Toward Deep Learning Algorithms on HPCC Systems
Moving Toward Deep Learning Algorithms on HPCC SystemsMoving Toward Deep Learning Algorithms on HPCC Systems
Moving Toward Deep Learning Algorithms on HPCC Systems
 
ScyllaDB V Developer Deep Dive Series: Resiliency and Strong Consistency via ...
ScyllaDB V Developer Deep Dive Series: Resiliency and Strong Consistency via ...ScyllaDB V Developer Deep Dive Series: Resiliency and Strong Consistency via ...
ScyllaDB V Developer Deep Dive Series: Resiliency and Strong Consistency via ...
 
WSDM09-keynote
WSDM09-keynoteWSDM09-keynote
WSDM09-keynote
 
GraphTour - Neo4j Database Overview
GraphTour - Neo4j Database OverviewGraphTour - Neo4j Database Overview
GraphTour - Neo4j Database Overview
 
Automated Slow Query Analysis: Dex the Index Robot
Automated Slow Query Analysis: Dex the Index RobotAutomated Slow Query Analysis: Dex the Index Robot
Automated Slow Query Analysis: Dex the Index Robot
 
Conceptos básicos. Seminario web 1: Introducción a NoSQL
Conceptos básicos. Seminario web 1: Introducción a NoSQLConceptos básicos. Seminario web 1: Introducción a NoSQL
Conceptos básicos. Seminario web 1: Introducción a NoSQL
 
Deep Dive on Amazon DynamoDB
Deep Dive on Amazon DynamoDBDeep Dive on Amazon DynamoDB
Deep Dive on Amazon DynamoDB
 
Rockwell Automation TechED 2017 - AP05 - Enbridge Energy
Rockwell Automation TechED 2017 - AP05 - Enbridge EnergyRockwell Automation TechED 2017 - AP05 - Enbridge Energy
Rockwell Automation TechED 2017 - AP05 - Enbridge Energy
 

More from NETFest

.NET Fest 2019. Николай Балакин. Микрооптимизации в мире .NET
.NET Fest 2019. Николай Балакин. Микрооптимизации в мире .NET.NET Fest 2019. Николай Балакин. Микрооптимизации в мире .NET
.NET Fest 2019. Николай Балакин. Микрооптимизации в мире .NETNETFest
 
.NET Fest 2019. Сергей Калинец. Efficient Microservice Communication with .NE...
.NET Fest 2019. Сергей Калинец. Efficient Microservice Communication with .NE....NET Fest 2019. Сергей Калинец. Efficient Microservice Communication with .NE...
.NET Fest 2019. Сергей Калинец. Efficient Microservice Communication with .NE...NETFest
 
.NET Fest 2019. Оля Гавриш. Машинное обучение для .NET программистов
.NET Fest 2019. Оля Гавриш. Машинное обучение для .NET программистов.NET Fest 2019. Оля Гавриш. Машинное обучение для .NET программистов
.NET Fest 2019. Оля Гавриш. Машинное обучение для .NET программистовNETFest
 
.NET Fest 2019. Roberto Freato. Provisioning Azure PaaS fluently with Managem...
.NET Fest 2019. Roberto Freato. Provisioning Azure PaaS fluently with Managem....NET Fest 2019. Roberto Freato. Provisioning Azure PaaS fluently with Managem...
.NET Fest 2019. Roberto Freato. Provisioning Azure PaaS fluently with Managem...NETFest
 
.NET Fest 2019. Halil Ibrahim Kalkan. Implementing Domain Driven Design
.NET Fest 2019. Halil Ibrahim Kalkan. Implementing Domain Driven Design.NET Fest 2019. Halil Ibrahim Kalkan. Implementing Domain Driven Design
.NET Fest 2019. Halil Ibrahim Kalkan. Implementing Domain Driven DesignNETFest
 
.NET Fest 2019. Сергій Бута. Feature Toggles: Dynamic Configuration at Wirex
.NET Fest 2019. Сергій Бута. Feature Toggles: Dynamic Configuration at Wirex.NET Fest 2019. Сергій Бута. Feature Toggles: Dynamic Configuration at Wirex
.NET Fest 2019. Сергій Бута. Feature Toggles: Dynamic Configuration at WirexNETFest
 
.NET Fest 2019. Michael Staib. Hot Chocolate: GraphQL Schema Stitching with A...
.NET Fest 2019. Michael Staib. Hot Chocolate: GraphQL Schema Stitching with A....NET Fest 2019. Michael Staib. Hot Chocolate: GraphQL Schema Stitching with A...
.NET Fest 2019. Michael Staib. Hot Chocolate: GraphQL Schema Stitching with A...NETFest
 
.NET Fest 2019. Андрей Литвинов. Async lifetime tests with xUnit and AutoFixture
.NET Fest 2019. Андрей Литвинов. Async lifetime tests with xUnit and AutoFixture.NET Fest 2019. Андрей Литвинов. Async lifetime tests with xUnit and AutoFixture
.NET Fest 2019. Андрей Литвинов. Async lifetime tests with xUnit and AutoFixtureNETFest
 
.NET Fest 2019. Анатолий Колесник. Love, Death & F# Tests
.NET Fest 2019. Анатолий Колесник. Love, Death & F# Tests.NET Fest 2019. Анатолий Колесник. Love, Death & F# Tests
.NET Fest 2019. Анатолий Колесник. Love, Death & F# TestsNETFest
 
.NET Fest 2019. Алексей Голуб. Монадные парсер-комбинаторы в C# (простой спос...
.NET Fest 2019. Алексей Голуб. Монадные парсер-комбинаторы в C# (простой спос....NET Fest 2019. Алексей Голуб. Монадные парсер-комбинаторы в C# (простой спос...
.NET Fest 2019. Алексей Голуб. Монадные парсер-комбинаторы в C# (простой спос...NETFest
 
.NET Fest 2019. Roberto Freato. Azure App Service deep dive
.NET Fest 2019. Roberto Freato. Azure App Service deep dive.NET Fest 2019. Roberto Freato. Azure App Service deep dive
.NET Fest 2019. Roberto Freato. Azure App Service deep diveNETFest
 
.NET Fest 2019. Леонид Молотиевский. DotNet Core in production
.NET Fest 2019. Леонид Молотиевский. DotNet Core in production.NET Fest 2019. Леонид Молотиевский. DotNet Core in production
.NET Fest 2019. Леонид Молотиевский. DotNet Core in productionNETFest
 
.NET Fest 2019. Александр Демчук. How to measure relationships within the Com...
.NET Fest 2019. Александр Демчук. How to measure relationships within the Com....NET Fest 2019. Александр Демчук. How to measure relationships within the Com...
.NET Fest 2019. Александр Демчук. How to measure relationships within the Com...NETFest
 
.NET Fest 2019. Anna Melashkina та Philipp Bauknecht. Dragons in a Mixed Real...
.NET Fest 2019. Anna Melashkina та Philipp Bauknecht. Dragons in a Mixed Real....NET Fest 2019. Anna Melashkina та Philipp Bauknecht. Dragons in a Mixed Real...
.NET Fest 2019. Anna Melashkina та Philipp Bauknecht. Dragons in a Mixed Real...NETFest
 
.NET Fest 2019. Alex Thissen. Architecting .NET solutions in a Docker ecosystem
.NET Fest 2019. Alex Thissen. Architecting .NET solutions in a Docker ecosystem.NET Fest 2019. Alex Thissen. Architecting .NET solutions in a Docker ecosystem
.NET Fest 2019. Alex Thissen. Architecting .NET solutions in a Docker ecosystemNETFest
 
.NET Fest 2019. Stas Lebedenko. Practical serverless use cases in Azure with ...
.NET Fest 2019. Stas Lebedenko. Practical serverless use cases in Azure with ....NET Fest 2019. Stas Lebedenko. Practical serverless use cases in Azure with ...
.NET Fest 2019. Stas Lebedenko. Practical serverless use cases in Azure with ...NETFest
 
.NET Fest 2019. Сергей Корж. Natural Language Processing in .NET
.NET Fest 2019. Сергей Корж. Natural Language Processing in .NET.NET Fest 2019. Сергей Корж. Natural Language Processing in .NET
.NET Fest 2019. Сергей Корж. Natural Language Processing in .NETNETFest
 
.NET Fest 2019. Eran Stiller. Create Your Own Serverless PKI with .NET & Azur...
.NET Fest 2019. Eran Stiller. Create Your Own Serverless PKI with .NET & Azur....NET Fest 2019. Eran Stiller. Create Your Own Serverless PKI with .NET & Azur...
.NET Fest 2019. Eran Stiller. Create Your Own Serverless PKI with .NET & Azur...NETFest
 
.NET Fest 2019. Eran Stiller. 6 Lessons I Learned on My Journey from Monolith...
.NET Fest 2019. Eran Stiller. 6 Lessons I Learned on My Journey from Monolith....NET Fest 2019. Eran Stiller. 6 Lessons I Learned on My Journey from Monolith...
.NET Fest 2019. Eran Stiller. 6 Lessons I Learned on My Journey from Monolith...NETFest
 
.NET Fest 2019. Kevin Dockx. Uncovering Swagger/OpenAPI
.NET Fest 2019. Kevin Dockx. Uncovering Swagger/OpenAPI.NET Fest 2019. Kevin Dockx. Uncovering Swagger/OpenAPI
.NET Fest 2019. Kevin Dockx. Uncovering Swagger/OpenAPINETFest
 

More from NETFest (20)

.NET Fest 2019. Николай Балакин. Микрооптимизации в мире .NET
.NET Fest 2019. Николай Балакин. Микрооптимизации в мире .NET.NET Fest 2019. Николай Балакин. Микрооптимизации в мире .NET
.NET Fest 2019. Николай Балакин. Микрооптимизации в мире .NET
 
.NET Fest 2019. Сергей Калинец. Efficient Microservice Communication with .NE...
.NET Fest 2019. Сергей Калинец. Efficient Microservice Communication with .NE....NET Fest 2019. Сергей Калинец. Efficient Microservice Communication with .NE...
.NET Fest 2019. Сергей Калинец. Efficient Microservice Communication with .NE...
 
.NET Fest 2019. Оля Гавриш. Машинное обучение для .NET программистов
.NET Fest 2019. Оля Гавриш. Машинное обучение для .NET программистов.NET Fest 2019. Оля Гавриш. Машинное обучение для .NET программистов
.NET Fest 2019. Оля Гавриш. Машинное обучение для .NET программистов
 
.NET Fest 2019. Roberto Freato. Provisioning Azure PaaS fluently with Managem...
.NET Fest 2019. Roberto Freato. Provisioning Azure PaaS fluently with Managem....NET Fest 2019. Roberto Freato. Provisioning Azure PaaS fluently with Managem...
.NET Fest 2019. Roberto Freato. Provisioning Azure PaaS fluently with Managem...
 
.NET Fest 2019. Halil Ibrahim Kalkan. Implementing Domain Driven Design
.NET Fest 2019. Halil Ibrahim Kalkan. Implementing Domain Driven Design.NET Fest 2019. Halil Ibrahim Kalkan. Implementing Domain Driven Design
.NET Fest 2019. Halil Ibrahim Kalkan. Implementing Domain Driven Design
 
.NET Fest 2019. Сергій Бута. Feature Toggles: Dynamic Configuration at Wirex
.NET Fest 2019. Сергій Бута. Feature Toggles: Dynamic Configuration at Wirex.NET Fest 2019. Сергій Бута. Feature Toggles: Dynamic Configuration at Wirex
.NET Fest 2019. Сергій Бута. Feature Toggles: Dynamic Configuration at Wirex
 
.NET Fest 2019. Michael Staib. Hot Chocolate: GraphQL Schema Stitching with A...
.NET Fest 2019. Michael Staib. Hot Chocolate: GraphQL Schema Stitching with A....NET Fest 2019. Michael Staib. Hot Chocolate: GraphQL Schema Stitching with A...
.NET Fest 2019. Michael Staib. Hot Chocolate: GraphQL Schema Stitching with A...
 
.NET Fest 2019. Андрей Литвинов. Async lifetime tests with xUnit and AutoFixture
.NET Fest 2019. Андрей Литвинов. Async lifetime tests with xUnit and AutoFixture.NET Fest 2019. Андрей Литвинов. Async lifetime tests with xUnit and AutoFixture
.NET Fest 2019. Андрей Литвинов. Async lifetime tests with xUnit and AutoFixture
 
.NET Fest 2019. Анатолий Колесник. Love, Death & F# Tests
.NET Fest 2019. Анатолий Колесник. Love, Death & F# Tests.NET Fest 2019. Анатолий Колесник. Love, Death & F# Tests
.NET Fest 2019. Анатолий Колесник. Love, Death & F# Tests
 
.NET Fest 2019. Алексей Голуб. Монадные парсер-комбинаторы в C# (простой спос...
.NET Fest 2019. Алексей Голуб. Монадные парсер-комбинаторы в C# (простой спос....NET Fest 2019. Алексей Голуб. Монадные парсер-комбинаторы в C# (простой спос...
.NET Fest 2019. Алексей Голуб. Монадные парсер-комбинаторы в C# (простой спос...
 
.NET Fest 2019. Roberto Freato. Azure App Service deep dive
.NET Fest 2019. Roberto Freato. Azure App Service deep dive.NET Fest 2019. Roberto Freato. Azure App Service deep dive
.NET Fest 2019. Roberto Freato. Azure App Service deep dive
 
.NET Fest 2019. Леонид Молотиевский. DotNet Core in production
.NET Fest 2019. Леонид Молотиевский. DotNet Core in production.NET Fest 2019. Леонид Молотиевский. DotNet Core in production
.NET Fest 2019. Леонид Молотиевский. DotNet Core in production
 
.NET Fest 2019. Александр Демчук. How to measure relationships within the Com...
.NET Fest 2019. Александр Демчук. How to measure relationships within the Com....NET Fest 2019. Александр Демчук. How to measure relationships within the Com...
.NET Fest 2019. Александр Демчук. How to measure relationships within the Com...
 
.NET Fest 2019. Anna Melashkina та Philipp Bauknecht. Dragons in a Mixed Real...
.NET Fest 2019. Anna Melashkina та Philipp Bauknecht. Dragons in a Mixed Real....NET Fest 2019. Anna Melashkina та Philipp Bauknecht. Dragons in a Mixed Real...
.NET Fest 2019. Anna Melashkina та Philipp Bauknecht. Dragons in a Mixed Real...
 
.NET Fest 2019. Alex Thissen. Architecting .NET solutions in a Docker ecosystem
.NET Fest 2019. Alex Thissen. Architecting .NET solutions in a Docker ecosystem.NET Fest 2019. Alex Thissen. Architecting .NET solutions in a Docker ecosystem
.NET Fest 2019. Alex Thissen. Architecting .NET solutions in a Docker ecosystem
 
.NET Fest 2019. Stas Lebedenko. Practical serverless use cases in Azure with ...
.NET Fest 2019. Stas Lebedenko. Practical serverless use cases in Azure with ....NET Fest 2019. Stas Lebedenko. Practical serverless use cases in Azure with ...
.NET Fest 2019. Stas Lebedenko. Practical serverless use cases in Azure with ...
 
.NET Fest 2019. Сергей Корж. Natural Language Processing in .NET
.NET Fest 2019. Сергей Корж. Natural Language Processing in .NET.NET Fest 2019. Сергей Корж. Natural Language Processing in .NET
.NET Fest 2019. Сергей Корж. Natural Language Processing in .NET
 
.NET Fest 2019. Eran Stiller. Create Your Own Serverless PKI with .NET & Azur...
.NET Fest 2019. Eran Stiller. Create Your Own Serverless PKI with .NET & Azur....NET Fest 2019. Eran Stiller. Create Your Own Serverless PKI with .NET & Azur...
.NET Fest 2019. Eran Stiller. Create Your Own Serverless PKI with .NET & Azur...
 
.NET Fest 2019. Eran Stiller. 6 Lessons I Learned on My Journey from Monolith...
.NET Fest 2019. Eran Stiller. 6 Lessons I Learned on My Journey from Monolith....NET Fest 2019. Eran Stiller. 6 Lessons I Learned on My Journey from Monolith...
.NET Fest 2019. Eran Stiller. 6 Lessons I Learned on My Journey from Monolith...
 
.NET Fest 2019. Kevin Dockx. Uncovering Swagger/OpenAPI
.NET Fest 2019. Kevin Dockx. Uncovering Swagger/OpenAPI.NET Fest 2019. Kevin Dockx. Uncovering Swagger/OpenAPI
.NET Fest 2019. Kevin Dockx. Uncovering Swagger/OpenAPI
 

Recently uploaded

Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Celine George
 
Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Seán Kennedy
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for BeginnersSabitha Banu
 
Food processing presentation for bsc agriculture hons
Food processing presentation for bsc agriculture honsFood processing presentation for bsc agriculture hons
Food processing presentation for bsc agriculture honsManeerUddin
 
4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptx4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptxmary850239
 
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...Postal Advocate Inc.
 
ROLES IN A STAGE PRODUCTION in arts.pptx
ROLES IN A STAGE PRODUCTION in arts.pptxROLES IN A STAGE PRODUCTION in arts.pptx
ROLES IN A STAGE PRODUCTION in arts.pptxVanesaIglesias10
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPCeline George
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...Nguyen Thanh Tu Collection
 
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...JojoEDelaCruz
 
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSGRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSJoshuaGantuangco2
 
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfGrade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfJemuel Francisco
 
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptxQ4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptxlancelewisportillo
 
Daily Lesson Plan in Mathematics Quarter 4
Daily Lesson Plan in Mathematics Quarter 4Daily Lesson Plan in Mathematics Quarter 4
Daily Lesson Plan in Mathematics Quarter 4JOYLYNSAMANIEGO
 
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxBarangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxCarlos105
 
Concurrency Control in Database Management system
Concurrency Control in Database Management systemConcurrency Control in Database Management system
Concurrency Control in Database Management systemChristalin Nelson
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17Celine George
 
4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptxmary850239
 

Recently uploaded (20)

Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
 
Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for Beginners
 
Food processing presentation for bsc agriculture hons
Food processing presentation for bsc agriculture honsFood processing presentation for bsc agriculture hons
Food processing presentation for bsc agriculture hons
 
4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptx4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptx
 
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
 
ROLES IN A STAGE PRODUCTION in arts.pptx
ROLES IN A STAGE PRODUCTION in arts.pptxROLES IN A STAGE PRODUCTION in arts.pptx
ROLES IN A STAGE PRODUCTION in arts.pptx
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERP
 
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptxYOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
 
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...
 
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSGRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
 
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptxYOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
 
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfGrade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
 
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptxQ4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
 
Daily Lesson Plan in Mathematics Quarter 4
Daily Lesson Plan in Mathematics Quarter 4Daily Lesson Plan in Mathematics Quarter 4
Daily Lesson Plan in Mathematics Quarter 4
 
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxBarangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
 
Concurrency Control in Database Management system
Concurrency Control in Database Management systemConcurrency Control in Database Management system
Concurrency Control in Database Management system
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17
 
4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx
 

.NET Fest 2019. Денис Резник. Когда SQL Server Best Practices не работают

  • 1. Тема доклада Тема доклада Тема доклада KYIV 2019 When SQL Server Best Practices do not work .NET CONFERENCE #1 IN UKRAINE
  • 2. Тема доклада Тема доклада Тема доклада .NET LEVEL UP About Me .NET CONFERENCE #1 IN UKRAINE KYIV 2019 • Denis Reznik • Kyiv, Ukraine • Data Architect at Intapp, Inc. • Microsoft Data Platform MVP • Co-Founder of Ukrainian Data Community Kyiv • PASS Regional Mentor, CEE • Co-author of “SQL Server MVP Deep Dives 2”
  • 3. Тема доклада Тема доклада Тема доклада .NET LEVEL UP Agenda .NET CONFERENCE #1 IN UKRAINE KYIV 2019 • Database Should Be Normalized • Each Table Should Have a Clustered Index • Column Datatypes Should Be as Small as Possible • Cost Threshold for Parallelism Should be Higher Than Default • Max Degree of Parallelism Should Be Set to Best Practices Value • Bonus: NOLOCK Side Effect
  • 4. Тема доклада Тема доклада Тема доклада KYIV 2019 Database Should Be Normalized .NET CONFERENCE #1 IN UKRAINE
  • 5. .NET LEVEL UP First Normal Form (1NF) .NET CONFERENCE #1 IN UKRAINE KYIV 2019 Company User Phone Phone Type Microsoft John Dow +380969785732 NULL Microsoft John Dow +32345409123 NULL Microsoft Larry McGregor +45678904692 NULL Oracle Corp. John Snow +380988958371 NULL Amazon Jack Snack +23348902385 Home Amazon Jack Snack +69058763287 Work Each cell contains an atomic value Company User Phone Microsoft John Dow Tel1: +380969785732, Tel2: +32345409123 Microsoft Larry McGregor Tel: +45678904692 Oracle Corp. John Snow +380988958371 Amazon Jack Snack Home: +23348902385 Work: +69058763287 UsersUsers
  • 6. Тема доклада Тема доклада Тема доклада KYIV 2019 Database Should Be Normalized .NET CONFERENCE #1 IN UKRAINE Demo
  • 7. Тема доклада Тема доклада Тема доклада KYIV 2019 Database Should Be Normalized Conclusion .NET CONFERENCE #1 IN UKRAINE • Normalize when in makes sense • Denormalize when it makes sense • Do not know what to do? Normalize. • Do not afraid of Denormalization.
  • 8. Тема доклада Тема доклада Тема доклада KYIV 2019 Each Table Should Have a Clustered Index .NET CONFERENCE #1 IN UKRAINE
  • 9. Heap 1 .. 100 100 .. 1k 5K .. 6K 1K .. 5K 6K .. 7K 15K .. 21K 12K .. 15K 10K .. 11K 21K .. 22K 22K .. 41K 9K .. 10K 41K .. 51K 7K .. 8K 8K .. 9K 71K .. 1M 51K .. 71K 1M .. 2M 2M .. 3M
  • 10. Clustered Index … … 1 .. 1M 1 .. 2K 2K+1 .. 4K 1M-2K .. 1M 1 .. 300 301 .. 800 801 .. 1,5K 1,5K+1 .. 2K
  • 11. Index 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
  • 12. Non-Clustered Index … A .. Z A .. C C .. K X .. Z … 1 .. 1M 1 .. 2K 2K+1 .. 4K 1M-2K .. 1M SELECT * FROM Users WHERE Name = 'John Dow' 1 .. 2K 2K .. 4K 1M-2K .. 1M Clustered Index (Id) Non-Clustered Index (Name) Heap
  • 13. Тема доклада Тема доклада Тема доклада KYIV 2019 Each Table Should Have a Clustered Index .NET CONFERENCE #1 IN UKRAINE Demo
  • 14. Тема доклада Тема доклада Тема доклада KYIV 2019 Each Table Should Have a Clustered Index Conclusion .NET CONFERENCE #1 IN UKRAINE • Do not afraid Heaps • RID Lookup requires less IO than Key Lookup • Consider Heaps for: • High Key Lookup workloads • Big tables with high insert rate
  • 15. Тема доклада Тема доклада Тема доклада KYIV 2019 Column Datatypes Should Be as Small as Possible .NET CONFERENCE #1 IN UKRAINE
  • 16. Тема доклада Тема доклада Тема доклада .NET LEVEL UP Possible Size Reduction .NET CONFERENCE #1 IN UKRAINE KYIV 2019 • int (4 Bytes) -> smallint (2B) -> tinyint (1B) -> bit (up to 1 Byte) • float -> decimal • datetime -> smalldatetime(?) -> datetime2 • nchar (2 Bytes per character) -> char (1 Byte per character) • nvarchar (2 Bytes per character) -> varchar (1 Byte per character)
  • 17. Тема доклада Тема доклада Тема доклада KYIV 2019 Column Datatypes Should Be as Small as Possible .NET CONFERENCE #1 IN UKRAINE Demo
  • 18. .NET LEVEL UP Data Type Precedence .NET CONFERENCE #1 IN UKRAINE KYIV 2019 1. user-defined data types (highest) 2. sql_variant 3. xml 4. datetimeoffset 5. datetime2 6. datetime 7. smalldatetime 8. date 9. time 10. float 11. real 12. decimal 13. money 14. smallmoney 15. bigint 16. int 17. smallint 18. tinyint 19. bit
  • 19. Тема доклада Тема доклада Тема доклада KYIV 2019 Column Datatypes Should Be as Small as Possible Conclusion .NET CONFERENCE #1 IN UKRAINE • Works for almost all datatypes • Use correct datatypes for each column • Prefer (by default) nvarchar over varchar
  • 20. Тема доклада Тема доклада Тема доклада KYIV 2019 Cost Threshold for Parallelism Should be Higher Than Default .NET CONFERENCE #1 IN UKRAINE
  • 21. • Goal – get the optimal execution plan • “Optimal” = Plan with the smallest cost • Cost = sum_of_all_operators_costs(I/O + CPU + memory_consumption) Optimizer Query Tree Pre-Optimization Search for trivial plan Load statistics (simple) Simplification – syntax transformation Optimization
  • 22. Optimizer Phase 0 Load Statistics Exploration – Plan Alternatives Estimated cost < 0.2 Return Transaction Processing Plan Optimization
  • 23. Query Plan Alternatives SELECT * FROM Users u INNER JOIN Posts p ON u.Id = p.OwnerUserId WHERE u.DisplayName = 'John Snow' Users Posts Posts Users
  • 24. Query Plan Alternatives • 1 Table – 1 option • 2 Tables – 2 options • 3 Tables – 6 options • 4 Tables – 24 options • … • 10 Tables – 3628800 options • 1 Table – 1! • 2 Tables – 2! • 3 Tables – 3! • 4 Tables – 4! • … • 10 Tables – 10!
  • 25. Dynamic Programming • JOIN(A,B,C,D) • JOIN(A,B,D,C) • JOIN(A,C,D,B) • JOIN(A,D,B,C) • JOIN(A,D,C,B) • JOIN(B,A,C,D) • JOIN(B,A,D,C) • … • O(N!) • JOIN(A,B,C,D) • A – Optimal Access Path • B – Optimal Access Path • … pruning • (A,B) – Optimal Access Path • … pruning • (A,B),(C) • … pruning • O(𝑁2 𝑛−1 )
  • 26. Optimizer Phase 1 Next set of query rules Estimate parallel plan (estimation processed twice) • Max Degree of Parallelism • Cost Threshold for Parallelism Estimated cost < 1.0 Returns Quick Plan Optimization
  • 27. Тема доклада Тема доклада Тема доклада KYIV 2019 Cost Threshold for Parallelism Should be Higher Than Default .NET CONFERENCE #1 IN UKRAINE Demo
  • 28. Тема доклада Тема доклада Тема доклада KYIV 2019 Cost Threshold for Parallelism Should be Higher Than Default Conclusion .NET CONFERENCE #1 IN UKRAINE • Good to set it higher on a fresh server • Bad to set in higher for the working system • Setting it for a working system requires validation • Validate it for top 5-20 CPU intensive queries
  • 29. Тема доклада Тема доклада Тема доклада KYIV 2019 Max Degree of Parallelism Should Be Set to Best Practices Value .NET CONFERENCE #1 IN UKRAINE
  • 30. Parallel Query Execution • Amdal’s Law Thread 1 Thread 2 Thread 3 Thread 4 1s2s
  • 31. Optimizer Phase 2 (Last Phase) Full Set of Optimization Rules Indexed views Returns Full Query Plan • All planned checks were done • Good Enough Plan was Found • Timeout • Not Enough Memory Optimization
  • 32. Тема доклада Тема доклада Тема доклада KYIV 2019 Max Degree of Parallelism Should Be Set to Best Practices Value .NET CONFERENCE #1 IN UKRAINE Demo
  • 33. Тема доклада Тема доклада Тема доклада KYIV 2019 Max Degree of Parallelism Should Be Set to Best Practices Value Conclusion .NET CONFERENCE #1 IN UKRAINE • High DOP usually force query to waste CPU • But not in every situation • MAXDOP 1 gives the Optimizer a bit more time
  • 34. Тема доклада Тема доклада Тема доклада KYIV 2019 Bonus: NOLOCK Side Effect .NET CONFERENCE #1 IN UKRAINE
  • 35. Тема доклада Тема доклада Тема доклада KYIV 2019 Bonus: NOLOCK Side Effect .NET CONFERENCE #1 IN UKRAINE Demo
  • 36. Extent N Allocation Order Scan … 1 .. 1M 1 .. 2K 2K+1 .. 4K 1M-2K .. 1M Clustered Index (Id) Extent 1 Index Allocation Map (IAM) Extent 1 Extent 2 Extent N
  • 37. Тема доклада Тема доклада Тема доклада .NET LEVEL UP Summary .NET CONFERENCE #1 IN UKRAINE KYIV 2019 • Database Should Be Normalized • Each Table Should Have a Clustered Index • Column Datatypes Should Be as Small as Possible • Cost Threshold for Parallelism Should be Higher Than Default • Max Degree of Parallelism Should Be Set to Best Practices Value • Add “If it does make sense” after each of the statements above • Bonus: NOLOCK and Cursor Threshold
  • 38. Тема доклада Тема доклада Тема доклада KYIV 2019 When SQL Server Best Practices do not work .NET CONFERENCE #1 IN UKRAINE Denis Reznik Twitter: @denisreznik Email: denisreznik@gmail.com Blog: http://reznik.uneta.com.ua Facebook: https://www.facebook.com/denis.reznik.5 LinkedIn: http://ua.linkedin.com/pub/denis-reznik/3/502/234