SlideShare a Scribd company logo
1 of 21
By Raluca Marcu
Performance
Tuning And
Optimization
Microsoft SQL
Database
About me…
Education & Certifications
Experience - MSSQL DBA & Dev - 6+ years
Contact
Performance Issues
Logical Optimization
Administrative Optimization
 System Configurations
 Capacity Planning
 Monitoring & Maintenance – Indexes & Statistics Maintenance
 DB Architecture
 DB Design
 Coding – Refactoring TSQL
 Common Symptoms
 Common Causes
 Tools to use
Performance Issues - Common Symptoms
CPU bottlenecks
– Identify occasional peaks in processor vs. processor is
constantly under pressure
Memory bottlenecks
– Can result in slow application responsiveness, overall system
slowdown, or even application crashing
Network bottlenecks
– Hard to recognize and easy to confuse
I/O bottlenecks
– Manifested through long response times, application
slowdowns and tasks time-outs
Slow running queries
Performance Issues - Common Causes
CPU bottlenecks
– Insufficient hardware resources
– Badly designed processes -> Query tuning, improving execution plans, and
system reconfiguration
Memory bottlenecks
– Limitations in available memory and memory pressure
– Poor indexing (table scans)
Network bottlenecks
– Overload on a server or network -> data cannot flow as expected
I/O bottlenecks
– Caused by slow hardware used, bad storage solution design, configuration
– Unnecessary requests made by a database -> affects I/O traffic
– Frequent index scans, inefficient queries, and out of date statistics
Slow running queries
– Missing indexes, poor execution plans, bad application and schema design
Performance Issues – Tools to use: DMVs
Processor Pressure -> sys.dm_os_performance_counters
• counter type -> values shown are cumulative since the last SQL Server start => re-run in about 10
seconds
• Batch Requests/sec -> depends on hardware used -> should be under 1000
• SQL Compilations/sec -> less than 10% of Batch Requests/sec
• SQL Re-Compilations/sec -> less than 10% of SQL Compilations/sec
• Checkpoint pages/sec and Lazy writes/sec -> indicate whether dirty pages are flushed to disk too
often
• Lazy Writes/sec -> value should be below 20; value is constantly above => check Page Life
Expectancy -> Values < 300 seconds => memory pressure
Performance Issues – Tools to use: DMVs
CPU performance bottlenecks -> sys.dm_os_wait_stats
Performance Issues – Tools to use
Performance Monitor
Counters Description Recom
mende
d
value
Issue
Processor
Time
CPU Time <80% constantly higher than 80% =>
processor is under pressure
Memory
Available KB
Available Memory > 200
MB
< 100 MB for long time =>
insufficient memory on the server
Pages/sec shows the rate at which the pages are
written from disk to RAM and read from
RAM to disk
> 50 >50 => intensive memory activity
and possible overhead and memory
pressure
Buffer Cache
Hit Ratio 
shows the ratio of the data pages found
and read from the SQL Server buffer
cache and all data page requests
> 90 If a page doesn’t exist in the buffer
cache, it has to be read disk, which
downgrades performance
Average Disk
Queue Length
the average number of I/O operations that
are waiting to be written to or read from
disk and the number of currently
processed reads and writes
< 2 per
individu
al disk
higher values => I/O bottlenecks
Average Disk
Sec/Read
the average time in seconds needed to
read data from disk
< 8ms > 20ms => serious I/O issue
Average Disk
Sec/Write
the average time in seconds needed to
write data to disk
< 1ms > 4ms => bad performance
Performance Issues – Tools to use
SQL Server Profiler
– Which queries, functions and stored procedures were executed
– Track deadlocks
Administration Optimization – System Configurations
■ Install SQL Server on a 64bit system (never 32bit)
■ Max Server Memory – 80% -> 90%
■ Cost Threshold for Parallelism – between 20 and 50
■ Transactional Log -> VLFs, default value, default auto-
growth, maintenance, shrink
Administration Optimization – Capacity Planning
■ Random I/O separated from Sequential I/O
■ Separate large indexes and/or specific tables to
separate disks
■ Data partitioning
■ Database auto-growth
Monitoring & Maintenance – Indexes &
Statistics Maintenance
■ Maintenance Solution – Ola Hallengren (Free
Solution)
■ Indexes
■ Statistics - DBCC SHOW_STATISTICS
■ Backup & Recovery Strategies – RPO & RTO
– Always -> Create the recovery strategy and then work towards the
Backups
Logical Optimization – DB Architecture
■ Data access
– Proper indexing and defragmentation - Database Tuning Advisor's
– Move TSQL code from app into db – no ORMs
– Identify inefficient TSQL, re-factor
■ Scale-up vs scale-out:
– https://www.youtube.com/watch?
v=kZOREEkYJKs
Logical Optimization – DB Design
1NF (first Normal
Form)
Eliminate duplicative
columns from the same
table.
Create separate tables for
each group of related data
and identify each row with
a unique column or set of
columns (the primary key).
2NF (second Normal
Form)
Meet the requirements of
1NF.
Remove subsets of data
that apply to multiple rows
of a table and place them
in separate tables.
Create relationships
between these new tables
and their predecessors
through the use of foreign
keys.
3NF (third Normal
Form)
Meet the requirements of
2NF.
Remove columns that are
not dependent upon the
primary key.
Normalization
• 5 (+1) normal forms, noted 1NF to 5NF (+ 3.5NF or BCNF)
• 3NF – eliminate redundant data, ensure data integrity and
atomicity, eliminate data modification anomalies
Logical Optimization – DB Design
De-Normalize:
– Performance – in practice a fully normalized database may incur
costly queries for assembling the required data.
– Complexity – fully normalizing a database may lead to a big number
of tables, making the database difficult to understand and
maintain.
– Project requirements – for some specific project types the effort of
elaborating a good design is not justified.
Caution: when de-normalizing a database, extra care must be
taken about data integrity.
Logical Optimization – Coding
■ Query Plan:
– Actual Query Plan vs. Estimated Query Plan
– DBCC FREEPROCCACHE
– Live example
Logical Optimization – Coding
■ Query Plan:
– Statistics & Indexes
Logical Optimization – Coding
Logical Optimization – Coding Best Practices
Triggers
– Avoid using them
– Never use the same trigger for different triggering events (Insert, Update,
Delete)
Views
– Use SCHEMABINNDING option -> users will not modify the tables schema
– Use views for writing queries that access columns from multiple tables
Transactions
– Handle errors (Try-Catch Block)
– Try to avoid nested transactions
– Reduce the time period of resource locking (begin -> commit/rollback fast)
Stored procedures
– Do not use "SP_XXX" as a naming convention
– Use "Set Nocount On" to eliminate extra network trip
– Use WITH RECOMPILE clause (EXECUTE statement-first time) when the
index structure changes
Thank you…
Q & A Time!
Q&A…
1. Big data SQL server
2. How can get the best performing in .Net MVC
3. The Cluster deployment model for SQL? Optimal model with a hardware resources
sufficient for the problems need large data storage, much access read-write – cluster
failover
4. According to my experience there is a pretty common problem during removal must
anticipate that retrieve data for a list such as a list of products. Here the problem is
that we often have to run through a loop to get the data for each product and
information relating to the product eg price, variant, size, images .... This will create
numerous query. The usual way to do it will not always try to put away once all the
data of all such products take the price of all products one by one, taking all the
variant of a turn and when I need to show to get this data from memory without recall
db This will limit the number of queries to the database. But to do so beautiful, are
not a simple problem? Speakers said there are ways to do this are not you?

More Related Content

What's hot

Sql Server Performance Tuning
Sql Server Performance TuningSql Server Performance Tuning
Sql Server Performance TuningBala Subra
 
Getting Started with Amazon Redshift
Getting Started with Amazon RedshiftGetting Started with Amazon Redshift
Getting Started with Amazon RedshiftAmazon Web Services
 
Exploring Oracle Database Performance Tuning Best Practices for DBAs and Deve...
Exploring Oracle Database Performance Tuning Best Practices for DBAs and Deve...Exploring Oracle Database Performance Tuning Best Practices for DBAs and Deve...
Exploring Oracle Database Performance Tuning Best Practices for DBAs and Deve...Aaron Shilo
 
Oracle to Postgres Schema Migration Hustle
Oracle to Postgres Schema Migration HustleOracle to Postgres Schema Migration Hustle
Oracle to Postgres Schema Migration HustleEDB
 
Capacity Planning For Your Growing MongoDB Cluster
Capacity Planning For Your Growing MongoDB ClusterCapacity Planning For Your Growing MongoDB Cluster
Capacity Planning For Your Growing MongoDB ClusterMongoDB
 
Oracle Database in-Memory Overivew
Oracle Database in-Memory OverivewOracle Database in-Memory Overivew
Oracle Database in-Memory OverivewMaria Colgan
 
Oracle Database Performance Tuning Advanced Features and Best Practices for DBAs
Oracle Database Performance Tuning Advanced Features and Best Practices for DBAsOracle Database Performance Tuning Advanced Features and Best Practices for DBAs
Oracle Database Performance Tuning Advanced Features and Best Practices for DBAsZohar Elkayam
 
Oracle Database performance tuning using oratop
Oracle Database performance tuning using oratopOracle Database performance tuning using oratop
Oracle Database performance tuning using oratopSandesh Rao
 
Oracle backup and recovery
Oracle backup and recoveryOracle backup and recovery
Oracle backup and recoveryYogiji Creations
 
Database performance tuning and query optimization
Database performance tuning and query optimizationDatabase performance tuning and query optimization
Database performance tuning and query optimizationDhani Ahmad
 
Dataguard presentation
Dataguard presentationDataguard presentation
Dataguard presentationVimlendu Kumar
 
Oracle sql high performance tuning
Oracle sql high performance tuningOracle sql high performance tuning
Oracle sql high performance tuningGuy Harrison
 
Oracle 10g Performance: chapter 02 aas
Oracle 10g Performance: chapter 02 aasOracle 10g Performance: chapter 02 aas
Oracle 10g Performance: chapter 02 aasKyle Hailey
 

What's hot (20)

Sql server basics
Sql server basicsSql server basics
Sql server basics
 
(STG402) Amazon EBS Deep Dive
(STG402) Amazon EBS Deep Dive(STG402) Amazon EBS Deep Dive
(STG402) Amazon EBS Deep Dive
 
Sql server basics
Sql server basicsSql server basics
Sql server basics
 
Sql Server Performance Tuning
Sql Server Performance TuningSql Server Performance Tuning
Sql Server Performance Tuning
 
Getting Started with Amazon Redshift
Getting Started with Amazon RedshiftGetting Started with Amazon Redshift
Getting Started with Amazon Redshift
 
Exploring Oracle Database Performance Tuning Best Practices for DBAs and Deve...
Exploring Oracle Database Performance Tuning Best Practices for DBAs and Deve...Exploring Oracle Database Performance Tuning Best Practices for DBAs and Deve...
Exploring Oracle Database Performance Tuning Best Practices for DBAs and Deve...
 
Oracle to Postgres Schema Migration Hustle
Oracle to Postgres Schema Migration HustleOracle to Postgres Schema Migration Hustle
Oracle to Postgres Schema Migration Hustle
 
Capacity Planning For Your Growing MongoDB Cluster
Capacity Planning For Your Growing MongoDB ClusterCapacity Planning For Your Growing MongoDB Cluster
Capacity Planning For Your Growing MongoDB Cluster
 
Oracle ASM Training
Oracle ASM TrainingOracle ASM Training
Oracle ASM Training
 
Introduction to Amazon Athena
Introduction to Amazon AthenaIntroduction to Amazon Athena
Introduction to Amazon Athena
 
Oracle Database in-Memory Overivew
Oracle Database in-Memory OverivewOracle Database in-Memory Overivew
Oracle Database in-Memory Overivew
 
Oracle Database Performance Tuning Advanced Features and Best Practices for DBAs
Oracle Database Performance Tuning Advanced Features and Best Practices for DBAsOracle Database Performance Tuning Advanced Features and Best Practices for DBAs
Oracle Database Performance Tuning Advanced Features and Best Practices for DBAs
 
Oracle Database performance tuning using oratop
Oracle Database performance tuning using oratopOracle Database performance tuning using oratop
Oracle Database performance tuning using oratop
 
Oracle backup and recovery
Oracle backup and recoveryOracle backup and recovery
Oracle backup and recovery
 
Database performance tuning and query optimization
Database performance tuning and query optimizationDatabase performance tuning and query optimization
Database performance tuning and query optimization
 
Amazon Redshift
Amazon Redshift Amazon Redshift
Amazon Redshift
 
Oracle Tablespace - Basic
Oracle Tablespace - BasicOracle Tablespace - Basic
Oracle Tablespace - Basic
 
Dataguard presentation
Dataguard presentationDataguard presentation
Dataguard presentation
 
Oracle sql high performance tuning
Oracle sql high performance tuningOracle sql high performance tuning
Oracle sql high performance tuning
 
Oracle 10g Performance: chapter 02 aas
Oracle 10g Performance: chapter 02 aasOracle 10g Performance: chapter 02 aas
Oracle 10g Performance: chapter 02 aas
 

Viewers also liked

Software architecture for high traffic website
Software architecture for high traffic websiteSoftware architecture for high traffic website
Software architecture for high traffic websiteTung Nguyen Thanh
 
New in Visual Studio and TFS 2013
New in Visual Studio and TFS 2013New in Visual Studio and TFS 2013
New in Visual Studio and TFS 2013Tung Nguyen Thanh
 
SQL Cursor - kiểu dữ liệu Cursor (Kiểu dữ liệu con trỏ)
SQL Cursor - kiểu dữ liệu Cursor (Kiểu dữ liệu con trỏ)SQL Cursor - kiểu dữ liệu Cursor (Kiểu dữ liệu con trỏ)
SQL Cursor - kiểu dữ liệu Cursor (Kiểu dữ liệu con trỏ)Pix Nhox
 
Tối ưu-cau-lệnh-oracle-sql
Tối ưu-cau-lệnh-oracle-sqlTối ưu-cau-lệnh-oracle-sql
Tối ưu-cau-lệnh-oracle-sqlViet Tran
 
SQL Server Optimization Checklist
SQL Server Optimization ChecklistSQL Server Optimization Checklist
SQL Server Optimization ChecklistGrant Fritchey
 
TSQL Advanced Query Techniques
TSQL Advanced Query TechniquesTSQL Advanced Query Techniques
TSQL Advanced Query TechniquesGianluca Sartori
 
Monitoring Oracle Database Instances with Zabbix
Monitoring Oracle Database Instances with ZabbixMonitoring Oracle Database Instances with Zabbix
Monitoring Oracle Database Instances with ZabbixGerger
 
Intro To TSQL - Unit 1
Intro To TSQL - Unit 1Intro To TSQL - Unit 1
Intro To TSQL - Unit 1iccma
 
Continuous Delivery with VS2015 and TFS2015
Continuous Delivery with VS2015 and TFS2015Continuous Delivery with VS2015 and TFS2015
Continuous Delivery with VS2015 and TFS2015Tung Nguyen Thanh
 
7a advanced tsql
7a   advanced tsql7a   advanced tsql
7a advanced tsqlNauman R
 
Visual studio 2015 ide new features
Visual studio 2015 ide new featuresVisual studio 2015 ide new features
Visual studio 2015 ide new featuresTung Nguyen Thanh
 
Chuong 4 - CSDL phân tán
Chuong 4 - CSDL phân tánChuong 4 - CSDL phân tán
Chuong 4 - CSDL phân tánduysu
 
Dữ liệu không gian trên SQL Server - (Spatial Data in SQL Server)
Dữ liệu không gian trên SQL Server - (Spatial Data in SQL Server)Dữ liệu không gian trên SQL Server - (Spatial Data in SQL Server)
Dữ liệu không gian trên SQL Server - (Spatial Data in SQL Server)Truong Ho
 
التحدى 6 الإستعلام بطريقة المعالج
التحدى 6 الإستعلام بطريقة المعالجالتحدى 6 الإستعلام بطريقة المعالج
التحدى 6 الإستعلام بطريقة المعالجbosy sadek
 
Lesson4 Protect and maintain databases
Lesson4 Protect and maintain databases Lesson4 Protect and maintain databases
Lesson4 Protect and maintain databases Abdullatif Tarakji
 

Viewers also liked (20)

Software architecture for high traffic website
Software architecture for high traffic websiteSoftware architecture for high traffic website
Software architecture for high traffic website
 
SignalR with ASP.NET MVC 6
SignalR with ASP.NET MVC 6SignalR with ASP.NET MVC 6
SignalR with ASP.NET MVC 6
 
New in Visual Studio and TFS 2013
New in Visual Studio and TFS 2013New in Visual Studio and TFS 2013
New in Visual Studio and TFS 2013
 
SQL Cursor - kiểu dữ liệu Cursor (Kiểu dữ liệu con trỏ)
SQL Cursor - kiểu dữ liệu Cursor (Kiểu dữ liệu con trỏ)SQL Cursor - kiểu dữ liệu Cursor (Kiểu dữ liệu con trỏ)
SQL Cursor - kiểu dữ liệu Cursor (Kiểu dữ liệu con trỏ)
 
Tối ưu-cau-lệnh-oracle-sql
Tối ưu-cau-lệnh-oracle-sqlTối ưu-cau-lệnh-oracle-sql
Tối ưu-cau-lệnh-oracle-sql
 
Refactoring code in .net
Refactoring code in .netRefactoring code in .net
Refactoring code in .net
 
SQL Server Optimization Checklist
SQL Server Optimization ChecklistSQL Server Optimization Checklist
SQL Server Optimization Checklist
 
TSQL Advanced Query Techniques
TSQL Advanced Query TechniquesTSQL Advanced Query Techniques
TSQL Advanced Query Techniques
 
Monitoring Oracle Database Instances with Zabbix
Monitoring Oracle Database Instances with ZabbixMonitoring Oracle Database Instances with Zabbix
Monitoring Oracle Database Instances with Zabbix
 
Intro To TSQL - Unit 1
Intro To TSQL - Unit 1Intro To TSQL - Unit 1
Intro To TSQL - Unit 1
 
Continuous Delivery with VS2015 and TFS2015
Continuous Delivery with VS2015 and TFS2015Continuous Delivery with VS2015 and TFS2015
Continuous Delivery with VS2015 and TFS2015
 
7a advanced tsql
7a   advanced tsql7a   advanced tsql
7a advanced tsql
 
Visual studio 2015 ide new features
Visual studio 2015 ide new featuresVisual studio 2015 ide new features
Visual studio 2015 ide new features
 
Chuong 4 - CSDL phân tán
Chuong 4 - CSDL phân tánChuong 4 - CSDL phân tán
Chuong 4 - CSDL phân tán
 
Dữ liệu không gian trên SQL Server - (Spatial Data in SQL Server)
Dữ liệu không gian trên SQL Server - (Spatial Data in SQL Server)Dữ liệu không gian trên SQL Server - (Spatial Data in SQL Server)
Dữ liệu không gian trên SQL Server - (Spatial Data in SQL Server)
 
التحدى 6 الإستعلام بطريقة المعالج
التحدى 6 الإستعلام بطريقة المعالجالتحدى 6 الإستعلام بطريقة المعالج
التحدى 6 الإستعلام بطريقة المعالج
 
Trabalho fitos digitais
Trabalho fitos digitaisTrabalho fitos digitais
Trabalho fitos digitais
 
Lesson4 Protect and maintain databases
Lesson4 Protect and maintain databases Lesson4 Protect and maintain databases
Lesson4 Protect and maintain databases
 
Lesson8 Manage Records
Lesson8 Manage RecordsLesson8 Manage Records
Lesson8 Manage Records
 
Lesson11 Create Query
Lesson11 Create QueryLesson11 Create Query
Lesson11 Create Query
 

Similar to Performance Tuning And Optimization Microsoft SQL Database

Database Systems Design, Implementation, and Management
Database Systems Design, Implementation, and ManagementDatabase Systems Design, Implementation, and Management
Database Systems Design, Implementation, and ManagementOllieShoresna
 
Dynamics ax performance tuning
Dynamics ax performance tuningDynamics ax performance tuning
Dynamics ax performance tuningOutsourceAX
 
collab2011-tuning-ebusiness-421966.pdf
collab2011-tuning-ebusiness-421966.pdfcollab2011-tuning-ebusiness-421966.pdf
collab2011-tuning-ebusiness-421966.pdfElboulmaniMohamed
 
Java Developers, make the database work for you (NLJUG JFall 2010)
Java Developers, make the database work for you (NLJUG JFall 2010)Java Developers, make the database work for you (NLJUG JFall 2010)
Java Developers, make the database work for you (NLJUG JFall 2010)Lucas Jellema
 
SQL Server 2008 Development for Programmers
SQL Server 2008 Development for ProgrammersSQL Server 2008 Development for Programmers
SQL Server 2008 Development for ProgrammersAdam Hutson
 
Presentation cloud control enterprise manager 12c
Presentation   cloud control enterprise manager 12cPresentation   cloud control enterprise manager 12c
Presentation cloud control enterprise manager 12cxKinAnx
 
Best storage engine for MySQL
Best storage engine for MySQLBest storage engine for MySQL
Best storage engine for MySQLtomflemingh2
 
Troubleshooting SQL Server
Troubleshooting SQL ServerTroubleshooting SQL Server
Troubleshooting SQL ServerStephen Rose
 
Collaborate 2011-tuning-ebusiness-416502
Collaborate 2011-tuning-ebusiness-416502Collaborate 2011-tuning-ebusiness-416502
Collaborate 2011-tuning-ebusiness-416502kaziul Islam Bulbul
 
Real World Performance - OLTP
Real World Performance - OLTPReal World Performance - OLTP
Real World Performance - OLTPConnor McDonald
 
Sql server troubleshooting
Sql server troubleshootingSql server troubleshooting
Sql server troubleshootingNathan Winters
 
MySQL & Expression Engine EEUK2013
MySQL & Expression Engine EEUK2013MySQL & Expression Engine EEUK2013
MySQL & Expression Engine EEUK2013EEvolutionUK
 
Geek Sync | Performance Tune Like an MVP
Geek Sync | Performance Tune Like an MVPGeek Sync | Performance Tune Like an MVP
Geek Sync | Performance Tune Like an MVPIDERA Software
 
MemSQL 201: Advanced Tips and Tricks Webcast
MemSQL 201: Advanced Tips and Tricks WebcastMemSQL 201: Advanced Tips and Tricks Webcast
MemSQL 201: Advanced Tips and Tricks WebcastSingleStore
 
Maximizing performance via tuning and optimization
Maximizing performance via tuning and optimizationMaximizing performance via tuning and optimization
Maximizing performance via tuning and optimizationMariaDB plc
 
Maximizing performance via tuning and optimization
Maximizing performance via tuning and optimizationMaximizing performance via tuning and optimization
Maximizing performance via tuning and optimizationMariaDB plc
 
Modernizing your database with SQL Server 2019
Modernizing your database with SQL Server 2019Modernizing your database with SQL Server 2019
Modernizing your database with SQL Server 2019Antonios Chatzipavlis
 
Presentación Oracle Database Migración consideraciones 10g/11g/12c
Presentación Oracle Database Migración consideraciones 10g/11g/12cPresentación Oracle Database Migración consideraciones 10g/11g/12c
Presentación Oracle Database Migración consideraciones 10g/11g/12cRonald Francisco Vargas Quesada
 

Similar to Performance Tuning And Optimization Microsoft SQL Database (20)

Breaking data
Breaking dataBreaking data
Breaking data
 
Database Systems Design, Implementation, and Management
Database Systems Design, Implementation, and ManagementDatabase Systems Design, Implementation, and Management
Database Systems Design, Implementation, and Management
 
Dynamics ax performance tuning
Dynamics ax performance tuningDynamics ax performance tuning
Dynamics ax performance tuning
 
collab2011-tuning-ebusiness-421966.pdf
collab2011-tuning-ebusiness-421966.pdfcollab2011-tuning-ebusiness-421966.pdf
collab2011-tuning-ebusiness-421966.pdf
 
Sql Server
Sql ServerSql Server
Sql Server
 
Java Developers, make the database work for you (NLJUG JFall 2010)
Java Developers, make the database work for you (NLJUG JFall 2010)Java Developers, make the database work for you (NLJUG JFall 2010)
Java Developers, make the database work for you (NLJUG JFall 2010)
 
SQL Server 2008 Development for Programmers
SQL Server 2008 Development for ProgrammersSQL Server 2008 Development for Programmers
SQL Server 2008 Development for Programmers
 
Presentation cloud control enterprise manager 12c
Presentation   cloud control enterprise manager 12cPresentation   cloud control enterprise manager 12c
Presentation cloud control enterprise manager 12c
 
Best storage engine for MySQL
Best storage engine for MySQLBest storage engine for MySQL
Best storage engine for MySQL
 
Troubleshooting SQL Server
Troubleshooting SQL ServerTroubleshooting SQL Server
Troubleshooting SQL Server
 
Collaborate 2011-tuning-ebusiness-416502
Collaborate 2011-tuning-ebusiness-416502Collaborate 2011-tuning-ebusiness-416502
Collaborate 2011-tuning-ebusiness-416502
 
Real World Performance - OLTP
Real World Performance - OLTPReal World Performance - OLTP
Real World Performance - OLTP
 
Sql server troubleshooting
Sql server troubleshootingSql server troubleshooting
Sql server troubleshooting
 
MySQL & Expression Engine EEUK2013
MySQL & Expression Engine EEUK2013MySQL & Expression Engine EEUK2013
MySQL & Expression Engine EEUK2013
 
Geek Sync | Performance Tune Like an MVP
Geek Sync | Performance Tune Like an MVPGeek Sync | Performance Tune Like an MVP
Geek Sync | Performance Tune Like an MVP
 
MemSQL 201: Advanced Tips and Tricks Webcast
MemSQL 201: Advanced Tips and Tricks WebcastMemSQL 201: Advanced Tips and Tricks Webcast
MemSQL 201: Advanced Tips and Tricks Webcast
 
Maximizing performance via tuning and optimization
Maximizing performance via tuning and optimizationMaximizing performance via tuning and optimization
Maximizing performance via tuning and optimization
 
Maximizing performance via tuning and optimization
Maximizing performance via tuning and optimizationMaximizing performance via tuning and optimization
Maximizing performance via tuning and optimization
 
Modernizing your database with SQL Server 2019
Modernizing your database with SQL Server 2019Modernizing your database with SQL Server 2019
Modernizing your database with SQL Server 2019
 
Presentación Oracle Database Migración consideraciones 10g/11g/12c
Presentación Oracle Database Migración consideraciones 10g/11g/12cPresentación Oracle Database Migración consideraciones 10g/11g/12c
Presentación Oracle Database Migración consideraciones 10g/11g/12c
 

More from Tung Nguyen Thanh

How to become senior .net developer
How to become senior .net developerHow to become senior .net developer
How to become senior .net developerTung Nguyen Thanh
 
Domain Driven Design Introduction
Domain Driven Design IntroductionDomain Driven Design Introduction
Domain Driven Design IntroductionTung Nguyen Thanh
 
Agile .NET Development with BDD and Continuous Integration
Agile .NET Development with BDD and Continuous IntegrationAgile .NET Development with BDD and Continuous Integration
Agile .NET Development with BDD and Continuous IntegrationTung Nguyen Thanh
 
HaNoi Net Group Introduction
HaNoi Net Group IntroductionHaNoi Net Group Introduction
HaNoi Net Group IntroductionTung Nguyen Thanh
 
TDD - Test Driven Development
TDD - Test Driven DevelopmentTDD - Test Driven Development
TDD - Test Driven DevelopmentTung Nguyen Thanh
 
How to release every week case study of continuous integration
How to release every week case study of continuous integrationHow to release every week case study of continuous integration
How to release every week case study of continuous integrationTung Nguyen Thanh
 
Workshop fight legacy code write unit test
Workshop fight legacy code write unit testWorkshop fight legacy code write unit test
Workshop fight legacy code write unit testTung Nguyen Thanh
 
Developing windows phone 7 application with silverlight
Developing windows phone 7 application with silverlightDeveloping windows phone 7 application with silverlight
Developing windows phone 7 application with silverlightTung Nguyen Thanh
 
Top 100 .NET Interview Questions and Answers
Top 100 .NET Interview Questions and AnswersTop 100 .NET Interview Questions and Answers
Top 100 .NET Interview Questions and AnswersTung Nguyen Thanh
 
Visual studio2012 tipsandtricks
Visual studio2012 tipsandtricksVisual studio2012 tipsandtricks
Visual studio2012 tipsandtricksTung Nguyen Thanh
 
UI prototyping with ms expression blend sketch flow
UI prototyping with ms expression blend sketch flowUI prototyping with ms expression blend sketch flow
UI prototyping with ms expression blend sketch flowTung Nguyen Thanh
 

More from Tung Nguyen Thanh (16)

How to become senior .net developer
How to become senior .net developerHow to become senior .net developer
How to become senior .net developer
 
Docker for .net developer
Docker for .net developerDocker for .net developer
Docker for .net developer
 
Domain Driven Design Introduction
Domain Driven Design IntroductionDomain Driven Design Introduction
Domain Driven Design Introduction
 
Agile .NET Development with BDD and Continuous Integration
Agile .NET Development with BDD and Continuous IntegrationAgile .NET Development with BDD and Continuous Integration
Agile .NET Development with BDD and Continuous Integration
 
HaNoi Net Group Introduction
HaNoi Net Group IntroductionHaNoi Net Group Introduction
HaNoi Net Group Introduction
 
TDD - Test Driven Development
TDD - Test Driven DevelopmentTDD - Test Driven Development
TDD - Test Driven Development
 
Whatmakesoftwareflexible
WhatmakesoftwareflexibleWhatmakesoftwareflexible
Whatmakesoftwareflexible
 
How to release every week case study of continuous integration
How to release every week case study of continuous integrationHow to release every week case study of continuous integration
How to release every week case study of continuous integration
 
Xp not windows xp
Xp not windows xpXp not windows xp
Xp not windows xp
 
Is xp still extreme
Is xp still extremeIs xp still extreme
Is xp still extreme
 
Workshop fight legacy code write unit test
Workshop fight legacy code write unit testWorkshop fight legacy code write unit test
Workshop fight legacy code write unit test
 
Windows Phone Introduction
Windows Phone IntroductionWindows Phone Introduction
Windows Phone Introduction
 
Developing windows phone 7 application with silverlight
Developing windows phone 7 application with silverlightDeveloping windows phone 7 application with silverlight
Developing windows phone 7 application with silverlight
 
Top 100 .NET Interview Questions and Answers
Top 100 .NET Interview Questions and AnswersTop 100 .NET Interview Questions and Answers
Top 100 .NET Interview Questions and Answers
 
Visual studio2012 tipsandtricks
Visual studio2012 tipsandtricksVisual studio2012 tipsandtricks
Visual studio2012 tipsandtricks
 
UI prototyping with ms expression blend sketch flow
UI prototyping with ms expression blend sketch flowUI prototyping with ms expression blend sketch flow
UI prototyping with ms expression blend sketch flow
 

Recently uploaded

CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 

Recently uploaded (20)

CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 

Performance Tuning And Optimization Microsoft SQL Database

  • 1. By Raluca Marcu Performance Tuning And Optimization Microsoft SQL Database
  • 2. About me… Education & Certifications Experience - MSSQL DBA & Dev - 6+ years Contact
  • 3. Performance Issues Logical Optimization Administrative Optimization  System Configurations  Capacity Planning  Monitoring & Maintenance – Indexes & Statistics Maintenance  DB Architecture  DB Design  Coding – Refactoring TSQL  Common Symptoms  Common Causes  Tools to use
  • 4. Performance Issues - Common Symptoms CPU bottlenecks – Identify occasional peaks in processor vs. processor is constantly under pressure Memory bottlenecks – Can result in slow application responsiveness, overall system slowdown, or even application crashing Network bottlenecks – Hard to recognize and easy to confuse I/O bottlenecks – Manifested through long response times, application slowdowns and tasks time-outs Slow running queries
  • 5. Performance Issues - Common Causes CPU bottlenecks – Insufficient hardware resources – Badly designed processes -> Query tuning, improving execution plans, and system reconfiguration Memory bottlenecks – Limitations in available memory and memory pressure – Poor indexing (table scans) Network bottlenecks – Overload on a server or network -> data cannot flow as expected I/O bottlenecks – Caused by slow hardware used, bad storage solution design, configuration – Unnecessary requests made by a database -> affects I/O traffic – Frequent index scans, inefficient queries, and out of date statistics Slow running queries – Missing indexes, poor execution plans, bad application and schema design
  • 6. Performance Issues – Tools to use: DMVs Processor Pressure -> sys.dm_os_performance_counters • counter type -> values shown are cumulative since the last SQL Server start => re-run in about 10 seconds • Batch Requests/sec -> depends on hardware used -> should be under 1000 • SQL Compilations/sec -> less than 10% of Batch Requests/sec • SQL Re-Compilations/sec -> less than 10% of SQL Compilations/sec • Checkpoint pages/sec and Lazy writes/sec -> indicate whether dirty pages are flushed to disk too often • Lazy Writes/sec -> value should be below 20; value is constantly above => check Page Life Expectancy -> Values < 300 seconds => memory pressure
  • 7. Performance Issues – Tools to use: DMVs CPU performance bottlenecks -> sys.dm_os_wait_stats
  • 8. Performance Issues – Tools to use Performance Monitor Counters Description Recom mende d value Issue Processor Time CPU Time <80% constantly higher than 80% => processor is under pressure Memory Available KB Available Memory > 200 MB < 100 MB for long time => insufficient memory on the server Pages/sec shows the rate at which the pages are written from disk to RAM and read from RAM to disk > 50 >50 => intensive memory activity and possible overhead and memory pressure Buffer Cache Hit Ratio  shows the ratio of the data pages found and read from the SQL Server buffer cache and all data page requests > 90 If a page doesn’t exist in the buffer cache, it has to be read disk, which downgrades performance Average Disk Queue Length the average number of I/O operations that are waiting to be written to or read from disk and the number of currently processed reads and writes < 2 per individu al disk higher values => I/O bottlenecks Average Disk Sec/Read the average time in seconds needed to read data from disk < 8ms > 20ms => serious I/O issue Average Disk Sec/Write the average time in seconds needed to write data to disk < 1ms > 4ms => bad performance
  • 9. Performance Issues – Tools to use SQL Server Profiler – Which queries, functions and stored procedures were executed – Track deadlocks
  • 10. Administration Optimization – System Configurations ■ Install SQL Server on a 64bit system (never 32bit) ■ Max Server Memory – 80% -> 90% ■ Cost Threshold for Parallelism – between 20 and 50 ■ Transactional Log -> VLFs, default value, default auto- growth, maintenance, shrink
  • 11. Administration Optimization – Capacity Planning ■ Random I/O separated from Sequential I/O ■ Separate large indexes and/or specific tables to separate disks ■ Data partitioning ■ Database auto-growth
  • 12. Monitoring & Maintenance – Indexes & Statistics Maintenance ■ Maintenance Solution – Ola Hallengren (Free Solution) ■ Indexes ■ Statistics - DBCC SHOW_STATISTICS ■ Backup & Recovery Strategies – RPO & RTO – Always -> Create the recovery strategy and then work towards the Backups
  • 13. Logical Optimization – DB Architecture ■ Data access – Proper indexing and defragmentation - Database Tuning Advisor's – Move TSQL code from app into db – no ORMs – Identify inefficient TSQL, re-factor ■ Scale-up vs scale-out: – https://www.youtube.com/watch? v=kZOREEkYJKs
  • 14. Logical Optimization – DB Design 1NF (first Normal Form) Eliminate duplicative columns from the same table. Create separate tables for each group of related data and identify each row with a unique column or set of columns (the primary key). 2NF (second Normal Form) Meet the requirements of 1NF. Remove subsets of data that apply to multiple rows of a table and place them in separate tables. Create relationships between these new tables and their predecessors through the use of foreign keys. 3NF (third Normal Form) Meet the requirements of 2NF. Remove columns that are not dependent upon the primary key. Normalization • 5 (+1) normal forms, noted 1NF to 5NF (+ 3.5NF or BCNF) • 3NF – eliminate redundant data, ensure data integrity and atomicity, eliminate data modification anomalies
  • 15. Logical Optimization – DB Design De-Normalize: – Performance – in practice a fully normalized database may incur costly queries for assembling the required data. – Complexity – fully normalizing a database may lead to a big number of tables, making the database difficult to understand and maintain. – Project requirements – for some specific project types the effort of elaborating a good design is not justified. Caution: when de-normalizing a database, extra care must be taken about data integrity.
  • 16. Logical Optimization – Coding ■ Query Plan: – Actual Query Plan vs. Estimated Query Plan – DBCC FREEPROCCACHE – Live example
  • 17. Logical Optimization – Coding ■ Query Plan: – Statistics & Indexes
  • 19. Logical Optimization – Coding Best Practices Triggers – Avoid using them – Never use the same trigger for different triggering events (Insert, Update, Delete) Views – Use SCHEMABINNDING option -> users will not modify the tables schema – Use views for writing queries that access columns from multiple tables Transactions – Handle errors (Try-Catch Block) – Try to avoid nested transactions – Reduce the time period of resource locking (begin -> commit/rollback fast) Stored procedures – Do not use "SP_XXX" as a naming convention – Use "Set Nocount On" to eliminate extra network trip – Use WITH RECOMPILE clause (EXECUTE statement-first time) when the index structure changes
  • 20. Thank you… Q & A Time!
  • 21. Q&A… 1. Big data SQL server 2. How can get the best performing in .Net MVC 3. The Cluster deployment model for SQL? Optimal model with a hardware resources sufficient for the problems need large data storage, much access read-write – cluster failover 4. According to my experience there is a pretty common problem during removal must anticipate that retrieve data for a list such as a list of products. Here the problem is that we often have to run through a loop to get the data for each product and information relating to the product eg price, variant, size, images .... This will create numerous query. The usual way to do it will not always try to put away once all the data of all such products take the price of all products one by one, taking all the variant of a turn and when I need to show to get this data from memory without recall db This will limit the number of queries to the database. But to do so beautiful, are not a simple problem? Speakers said there are ways to do this are not you?