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

Zero Data Loss Recovery Appliance - Deep Dive
Zero Data Loss Recovery Appliance - Deep DiveZero Data Loss Recovery Appliance - Deep Dive
Zero Data Loss Recovery Appliance - Deep DiveDaniele Massimi
 
Database Performance Tuning
Database Performance Tuning Database Performance Tuning
Database Performance Tuning Arno Huetter
 
MySQL Performance Schema in Action
MySQL Performance Schema in ActionMySQL Performance Schema in Action
MySQL Performance Schema in ActionSveta Smirnova
 
RocksDB Performance and Reliability Practices
RocksDB Performance and Reliability PracticesRocksDB Performance and Reliability Practices
RocksDB Performance and Reliability PracticesYoshinori Matsunobu
 
PostGreSQL Performance Tuning
PostGreSQL Performance TuningPostGreSQL Performance Tuning
PostGreSQL Performance TuningMaven Logix
 
MySQL Atchitecture and Concepts
MySQL Atchitecture and ConceptsMySQL Atchitecture and Concepts
MySQL Atchitecture and ConceptsTuyen Vuong
 
Oracle - Checklist for performance issues
Oracle - Checklist for performance issuesOracle - Checklist for performance issues
Oracle - Checklist for performance issuesMarkus Flechtner
 
Open Source 101 2022 - MySQL Indexes and Histograms
Open Source 101 2022 - MySQL Indexes and HistogramsOpen Source 101 2022 - MySQL Indexes and Histograms
Open Source 101 2022 - MySQL Indexes and HistogramsFrederic Descamps
 
Data Quality With or Without Apache Spark and Its Ecosystem
Data Quality With or Without Apache Spark and Its EcosystemData Quality With or Without Apache Spark and Its Ecosystem
Data Quality With or Without Apache Spark and Its EcosystemDatabricks
 
SQL vs NoSQL | MySQL vs MongoDB Tutorial | Edureka
SQL vs NoSQL | MySQL vs MongoDB Tutorial | EdurekaSQL vs NoSQL | MySQL vs MongoDB Tutorial | Edureka
SQL vs NoSQL | MySQL vs MongoDB Tutorial | EdurekaEdureka!
 
Presto - Hadoop Conference Japan 2014
Presto - Hadoop Conference Japan 2014Presto - Hadoop Conference Japan 2014
Presto - Hadoop Conference Japan 2014Sadayuki Furuhashi
 
MySQL Performance Tuning: Top 10 Tips
MySQL Performance Tuning: Top 10 TipsMySQL Performance Tuning: Top 10 Tips
MySQL Performance Tuning: Top 10 TipsOSSCube
 
Introduction to MongoDB
Introduction to MongoDBIntroduction to MongoDB
Introduction to MongoDBMongoDB
 
Sql Server Performance Tuning
Sql Server Performance TuningSql Server Performance Tuning
Sql Server Performance TuningBala Subra
 
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
 
The Basics of MongoDB
The Basics of MongoDBThe Basics of MongoDB
The Basics of MongoDBvaluebound
 

What's hot (20)

Zero Data Loss Recovery Appliance - Deep Dive
Zero Data Loss Recovery Appliance - Deep DiveZero Data Loss Recovery Appliance - Deep Dive
Zero Data Loss Recovery Appliance - Deep Dive
 
Database Performance Tuning
Database Performance Tuning Database Performance Tuning
Database Performance Tuning
 
MySQL Performance Schema in Action
MySQL Performance Schema in ActionMySQL Performance Schema in Action
MySQL Performance Schema in Action
 
MySQL Tuning
MySQL TuningMySQL Tuning
MySQL Tuning
 
PostgreSQL
PostgreSQLPostgreSQL
PostgreSQL
 
RocksDB Performance and Reliability Practices
RocksDB Performance and Reliability PracticesRocksDB Performance and Reliability Practices
RocksDB Performance and Reliability Practices
 
PostGreSQL Performance Tuning
PostGreSQL Performance TuningPostGreSQL Performance Tuning
PostGreSQL Performance Tuning
 
Performance tuning in sql server
Performance tuning in sql serverPerformance tuning in sql server
Performance tuning in sql server
 
MySQL Atchitecture and Concepts
MySQL Atchitecture and ConceptsMySQL Atchitecture and Concepts
MySQL Atchitecture and Concepts
 
Oracle - Checklist for performance issues
Oracle - Checklist for performance issuesOracle - Checklist for performance issues
Oracle - Checklist for performance issues
 
NoSql
NoSqlNoSql
NoSql
 
Open Source 101 2022 - MySQL Indexes and Histograms
Open Source 101 2022 - MySQL Indexes and HistogramsOpen Source 101 2022 - MySQL Indexes and Histograms
Open Source 101 2022 - MySQL Indexes and Histograms
 
Data Quality With or Without Apache Spark and Its Ecosystem
Data Quality With or Without Apache Spark and Its EcosystemData Quality With or Without Apache Spark and Its Ecosystem
Data Quality With or Without Apache Spark and Its Ecosystem
 
SQL vs NoSQL | MySQL vs MongoDB Tutorial | Edureka
SQL vs NoSQL | MySQL vs MongoDB Tutorial | EdurekaSQL vs NoSQL | MySQL vs MongoDB Tutorial | Edureka
SQL vs NoSQL | MySQL vs MongoDB Tutorial | Edureka
 
Presto - Hadoop Conference Japan 2014
Presto - Hadoop Conference Japan 2014Presto - Hadoop Conference Japan 2014
Presto - Hadoop Conference Japan 2014
 
MySQL Performance Tuning: Top 10 Tips
MySQL Performance Tuning: Top 10 TipsMySQL Performance Tuning: Top 10 Tips
MySQL Performance Tuning: Top 10 Tips
 
Introduction to MongoDB
Introduction to MongoDBIntroduction to MongoDB
Introduction to MongoDB
 
Sql Server Performance Tuning
Sql Server Performance TuningSql Server Performance Tuning
Sql Server Performance Tuning
 
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...
 
The Basics of MongoDB
The Basics of MongoDBThe Basics of MongoDB
The Basics of MongoDB
 

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
 
Database performance tuning and query optimization
Database performance tuning and query optimizationDatabase performance tuning and query optimization
Database performance tuning and query optimizationDhani Ahmad
 
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
 

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
 
Database performance tuning and query optimization
Database performance tuning and query optimizationDatabase performance tuning and query optimization
Database performance tuning and query optimization
 
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
 

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

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
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Wonjun Hwang
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
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
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
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
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
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
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentationphoebematthew05
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
"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
 
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
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 

Recently uploaded (20)

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
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
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
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
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
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
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?
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentation
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
"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...
 
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
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 

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?