SlideShare uma empresa Scribd logo
1 de 25
Baixar para ler offline
Practical SQL Query Monitoring 
and Optimization 
Identify Data Layer Bottlenecks
About me 
 Project Manager @ 
 10 years professional experience 
 Microsoft Certified Specialist 
 ivelin.andreev@icb.bg 
 http://www.linkedin.com/in/ivelin 
 Business Interests 
 ASP.NET, AJAX, jQuery 
 SOA, Integration 
 GIS, Mapping 
 SQL optimization 
2 |
A Well Known Story 
Monitor and Measure Application 
Analyze Tier Interaction 
Getting Performance Hints 
Identify Problematic Queries 
Optimization Query Performance 
Measure the Effect 
Maintain 
3 |
Warning: A Bottleneck 
 Visual Studio Performance Wizard 
 CPU and Memory Sampling 
 Concurrency 
 Tier Interaction 
 SQL Server Profiler 
 Create trace 
 Analyze trace results 
 Replay trace 
 Log analyzer 
 Most frequent and timely queries 
 Identify long-running locks (and deadlocks) 
 Identify I/O activity 
 SQL Solutions Trace Analyzer / Deadlock Detector
Row vs. Chunk at a Time 
 Row at a time (RAT) processing 
 SELECT * FROM Activities WHERE ParentId = 1 
 SELECT * FROM Activities WHERE ParentId = 2 
 SELECT * FROM Activities WHERE ParentId = 16 
 Chunk at a time (CAT) processing 
 SELECT * FROM Activities WHERE ParentId IN (1,2,16) 
 Likely to happen when: 
 Components with own DataSource extraction 
 Complex code by different developers
DEMO 1 
 Row vs. Chunk at a Time 
 Analyzing Trace Logs
Getting Help 
 Analyze Execution Plan 
 Database Tuning Advisor 
 Suggests indexes and statistics 
 Opt.1: Improvement  20% 
 Opt.2: Improvement  20% 
 Dynamic Management Views 
 Missing Indexes (sys.dm_db_missing_index_groups) 
 Slowest Queries (sys.dm_exec_query_stats)
DEMO 2 
 Tuning Advisor 
 Dynamic Management Views
Analyze Query Plan 
 Tools 
 SQL Server Management Studio 
 SQL Sentry: free @ http://www.sqlsentry.com 
 Query Plan 
 Colour-scaled cost information 
 Cost filter by CPU, I/O or both 
 Better plan layout 
 Top Operations 
 Tuning Tips
Query Plan Basics 
 Table Scan (Heap) 
 Clustered index missing 
 Scans data pages (all data) 
 Index Scan 
 Scans index pages (less data) 
 Relies on order of pages 
 Index Seek 
 Highly selective queries (10-15% of rows) 
 Indexed Views 
 Require: Schema binding 
 Require: Deterministic functions
DEMO 3 
 Query Plan Explorer 
 OR vs. UNION
Indexes 
 Index types 
 Clustered / Non-clustered 
 Filtered index(SQL 2008) 
 Covering index 
 Objective 
 Optimal performance 
 Reduce slow scans 
 Difference in large data sets
Are Indexes Magical ? 
 Choosing Indexes 
 Measure query impact 
 Measure index size 
 Maintenance 
 Fragmentation = poor disk I/O 
 Reorganize vs. Rebuild 
 Automate: Nightly Job 
 Anti-patterns 
 Create indexes blindly 
 Execute non-indexable queries 
 SELECT * FROM Employees WHERE CAST(PNumber AS INT)  1 
 SELECT * FROM Customers WHERE ContactName LIKE ‘%a%’ 
 SELECT * FROM Employees WHERE FName=‘a’ OR LName=‘b’ 
 Reject indexes because of their overhead
SQL Server Statistics 
 Objective 
 WHERE clause order 
 Statistics on data distribution 
 Query Optimizer creates efficient plan 
 Up-to-date check 
 Automatically created for index keys 
 Estimated vs. Actual Rows 
Maintenance 
 DB Default: AUTOCREATE and AUTOUPDATE 
 EXEC sp_updatestats 
 Automate: Nightly Job
User Defined Functions 
 Procedures vs. Functions 
 Performance vs. Reusability 
 Complex conditions 
 Used through the whole application 
 i.e. IsCaseClosed 
 Chunk at a Time 
 Table valued parameters (SQL 2008 and on) 
 Pass result from one function to next
Optimize Locks 
Data Integrity 
 Data commit waits 
NOLOCK 
 Prevent Deadlocks 
 Returns uncommitted data 
 Incorrect results 
 Less/More rows could be returned 
 Update one entity, retrieve another 
 Index page splits under heavy load(GUID)
DEMO 4 
 The NOLOCK Problem
Common Table Expressions (CTE) 
 Alias of a query (SQL 2005) 
 Advantages 
 Readability and reusability 
 Implement recursive query 
 Materializes when used 
 Uses indexes (Table v@r not) 
 Disadvantages 
 Can be used only once 
 Must be used immediately
Other 
 UNION vs. UNION ALL 
 Data Types 
 Do you really need BIGINT? 
 Requires storage 
 Requires time to read 
 Requires memory 
BIGINT INT Delta (MB) Delta (%) 
Primary Key 1267 977 290 23% 
By_PropID_CountryID 813 741 72 9% 
By_String 303 230 73 24%
SQL Resource Governor 
 Shared DB Server 
 Prioritize queries 
 Reporting vs. Dashboard 
 Memory, CPU 
 Connections, Parallelism 
 RG Configuration 
 Pools 
 Workload Groups 
 Custom classification function 
 Available in SQL Server Enterprise
Test Under Load 
 Life’s complicated 
 Concurrent queries 
 Multiple user 
 Cached Buffers 
 Tools 
 SQL Server Profiler Replay 
 SQL Server 2012 Distributed Replay 
 Snap In @ http://dreplaygui.codeplex.com/ 
 SQL Load Generator 
 http://sqlloadgenerator.codeplex.com/
Summary 
 Steps 
 Capture/Analysis/Optimization 
 Measure the improvement 
 Maintain 
 Remember 
 Reoccurring improvement 
 Ideally you should analyze all SQL 
 Changes can affect SQL performance 
 in data size 
 result set size
DEMO 5 
 Trace Replay 
 SQL Load Generator 
 Resource Governor
Other Approaches 
 Caching 
 Application (Static) 
 Session 
 Context 
 WCF Session 
 Entity Framework Caching 
 Paging 
 Lazy loading 
 Parallel binding 
 Historical / Live data tables
SQL Saturday #152 Sponsors

Mais conteúdo relacionado

Mais procurados

Microsoft Azure Data Factory Hands-On Lab Overview Slides
Microsoft Azure Data Factory Hands-On Lab Overview SlidesMicrosoft Azure Data Factory Hands-On Lab Overview Slides
Microsoft Azure Data Factory Hands-On Lab Overview SlidesMark Kromer
 
Sql server performance tuning
Sql server performance tuningSql server performance tuning
Sql server performance tuningngupt28
 
Analyzing StackExchange Data with Azure Data Lake (Tom Kerkhove @ Integration...
Analyzing StackExchange Data with Azure Data Lake (Tom Kerkhove @ Integration...Analyzing StackExchange Data with Azure Data Lake (Tom Kerkhove @ Integration...
Analyzing StackExchange Data with Azure Data Lake (Tom Kerkhove @ Integration...Codit
 
Microsoft Azure Data Factory Data Flow Scenarios
Microsoft Azure Data Factory Data Flow ScenariosMicrosoft Azure Data Factory Data Flow Scenarios
Microsoft Azure Data Factory Data Flow ScenariosMark Kromer
 
TechDays NL 2016 - Building your scalable secure IoT Solution on Azure
TechDays NL 2016 - Building your scalable secure IoT Solution on AzureTechDays NL 2016 - Building your scalable secure IoT Solution on Azure
TechDays NL 2016 - Building your scalable secure IoT Solution on AzureTom Kerkhove
 
Why & how to optimize sql server for performance from design to query
Why & how to optimize sql server for performance from design to queryWhy & how to optimize sql server for performance from design to query
Why & how to optimize sql server for performance from design to queryAntonios Chatzipavlis
 
Pro Techniques for the SSAS MD Developer
Pro Techniques for the SSAS MD DeveloperPro Techniques for the SSAS MD Developer
Pro Techniques for the SSAS MD DeveloperJens Vestergaard
 
Using extended events for troubleshooting sql server
Using extended events for troubleshooting sql serverUsing extended events for troubleshooting sql server
Using extended events for troubleshooting sql serverAntonios Chatzipavlis
 
Tech-Spark: Azure SQL Databases
Tech-Spark: Azure SQL DatabasesTech-Spark: Azure SQL Databases
Tech-Spark: Azure SQL DatabasesRalph Attard
 
Azure Data Factory Data Flows Training v005
Azure Data Factory Data Flows Training v005Azure Data Factory Data Flows Training v005
Azure Data Factory Data Flows Training v005Mark Kromer
 
Sql server performance tuning and optimization
Sql server performance tuning and optimizationSql server performance tuning and optimization
Sql server performance tuning and optimizationManish Rawat
 
Azure data factory
Azure data factoryAzure data factory
Azure data factoryDavid Giard
 
Sql server performance tuning
Sql server performance tuningSql server performance tuning
Sql server performance tuningJugal Shah
 
ADF Mapping Data Flows Training V2
ADF Mapping Data Flows Training V2ADF Mapping Data Flows Training V2
ADF Mapping Data Flows Training V2Mark Kromer
 
Before you optimize: Understanding Execution Plans
Before you optimize: Understanding Execution PlansBefore you optimize: Understanding Execution Plans
Before you optimize: Understanding Execution PlansTimothy Corey
 
Accelerate Your ML Pipeline with AutoML and MLflow
Accelerate Your ML Pipeline with AutoML and MLflowAccelerate Your ML Pipeline with AutoML and MLflow
Accelerate Your ML Pipeline with AutoML and MLflowDatabricks
 
Azure Data Factory Data Wrangling with Power Query
Azure Data Factory Data Wrangling with Power QueryAzure Data Factory Data Wrangling with Power Query
Azure Data Factory Data Wrangling with Power QueryMark Kromer
 
Data quality patterns in the cloud with ADF
Data quality patterns in the cloud with ADFData quality patterns in the cloud with ADF
Data quality patterns in the cloud with ADFMark Kromer
 
ADF Mapping Data Flows Training Slides V1
ADF Mapping Data Flows Training Slides V1ADF Mapping Data Flows Training Slides V1
ADF Mapping Data Flows Training Slides V1Mark Kromer
 

Mais procurados (20)

Microsoft Azure Data Factory Hands-On Lab Overview Slides
Microsoft Azure Data Factory Hands-On Lab Overview SlidesMicrosoft Azure Data Factory Hands-On Lab Overview Slides
Microsoft Azure Data Factory Hands-On Lab Overview Slides
 
Sql server performance tuning
Sql server performance tuningSql server performance tuning
Sql server performance tuning
 
Analyzing StackExchange Data with Azure Data Lake (Tom Kerkhove @ Integration...
Analyzing StackExchange Data with Azure Data Lake (Tom Kerkhove @ Integration...Analyzing StackExchange Data with Azure Data Lake (Tom Kerkhove @ Integration...
Analyzing StackExchange Data with Azure Data Lake (Tom Kerkhove @ Integration...
 
Microsoft Azure Data Factory Data Flow Scenarios
Microsoft Azure Data Factory Data Flow ScenariosMicrosoft Azure Data Factory Data Flow Scenarios
Microsoft Azure Data Factory Data Flow Scenarios
 
TechDays NL 2016 - Building your scalable secure IoT Solution on Azure
TechDays NL 2016 - Building your scalable secure IoT Solution on AzureTechDays NL 2016 - Building your scalable secure IoT Solution on Azure
TechDays NL 2016 - Building your scalable secure IoT Solution on Azure
 
Why & how to optimize sql server for performance from design to query
Why & how to optimize sql server for performance from design to queryWhy & how to optimize sql server for performance from design to query
Why & how to optimize sql server for performance from design to query
 
Pro Techniques for the SSAS MD Developer
Pro Techniques for the SSAS MD DeveloperPro Techniques for the SSAS MD Developer
Pro Techniques for the SSAS MD Developer
 
Using extended events for troubleshooting sql server
Using extended events for troubleshooting sql serverUsing extended events for troubleshooting sql server
Using extended events for troubleshooting sql server
 
Tech-Spark: Azure SQL Databases
Tech-Spark: Azure SQL DatabasesTech-Spark: Azure SQL Databases
Tech-Spark: Azure SQL Databases
 
Azure Data Factory Data Flows Training v005
Azure Data Factory Data Flows Training v005Azure Data Factory Data Flows Training v005
Azure Data Factory Data Flows Training v005
 
Sql server performance tuning and optimization
Sql server performance tuning and optimizationSql server performance tuning and optimization
Sql server performance tuning and optimization
 
Azure data factory
Azure data factoryAzure data factory
Azure data factory
 
Sql server performance tuning
Sql server performance tuningSql server performance tuning
Sql server performance tuning
 
ADF Mapping Data Flows Training V2
ADF Mapping Data Flows Training V2ADF Mapping Data Flows Training V2
ADF Mapping Data Flows Training V2
 
Before you optimize: Understanding Execution Plans
Before you optimize: Understanding Execution PlansBefore you optimize: Understanding Execution Plans
Before you optimize: Understanding Execution Plans
 
Accelerate Your ML Pipeline with AutoML and MLflow
Accelerate Your ML Pipeline with AutoML and MLflowAccelerate Your ML Pipeline with AutoML and MLflow
Accelerate Your ML Pipeline with AutoML and MLflow
 
SQL Server 2016 BI updates
SQL Server 2016 BI updatesSQL Server 2016 BI updates
SQL Server 2016 BI updates
 
Azure Data Factory Data Wrangling with Power Query
Azure Data Factory Data Wrangling with Power QueryAzure Data Factory Data Wrangling with Power Query
Azure Data Factory Data Wrangling with Power Query
 
Data quality patterns in the cloud with ADF
Data quality patterns in the cloud with ADFData quality patterns in the cloud with ADF
Data quality patterns in the cloud with ADF
 
ADF Mapping Data Flows Training Slides V1
ADF Mapping Data Flows Training Slides V1ADF Mapping Data Flows Training Slides V1
ADF Mapping Data Flows Training Slides V1
 

Destaque

Spot db consistency checking and optimization in spatial database
Spot db  consistency checking and optimization in spatial databaseSpot db  consistency checking and optimization in spatial database
Spot db consistency checking and optimization in spatial databasePratik Udapure
 
Mongo db pefrormance optimization strategies
Mongo db pefrormance optimization strategiesMongo db pefrormance optimization strategies
Mongo db pefrormance optimization strategiesronwarshawsky
 
"MySQL Boosting - DB Best Practices & Optimization" by José Luis Martínez - C...
"MySQL Boosting - DB Best Practices & Optimization" by José Luis Martínez - C..."MySQL Boosting - DB Best Practices & Optimization" by José Luis Martínez - C...
"MySQL Boosting - DB Best Practices & Optimization" by José Luis Martínez - C...CAPSiDE
 
MySQL Performance Tips & Best Practices
MySQL Performance Tips & Best PracticesMySQL Performance Tips & Best Practices
MySQL Performance Tips & Best PracticesIsaac Mosquera
 
Performance Tuning And Optimization Microsoft SQL Database
Performance Tuning And Optimization Microsoft SQL DatabasePerformance Tuning And Optimization Microsoft SQL Database
Performance Tuning And Optimization Microsoft SQL DatabaseTung Nguyen Thanh
 
3 g huawei-wcdma-rno-parameters-optimization
3 g huawei-wcdma-rno-parameters-optimization3 g huawei-wcdma-rno-parameters-optimization
3 g huawei-wcdma-rno-parameters-optimizationshagahod
 

Destaque (7)

Sql db optimization
Sql db optimizationSql db optimization
Sql db optimization
 
Spot db consistency checking and optimization in spatial database
Spot db  consistency checking and optimization in spatial databaseSpot db  consistency checking and optimization in spatial database
Spot db consistency checking and optimization in spatial database
 
Mongo db pefrormance optimization strategies
Mongo db pefrormance optimization strategiesMongo db pefrormance optimization strategies
Mongo db pefrormance optimization strategies
 
"MySQL Boosting - DB Best Practices & Optimization" by José Luis Martínez - C...
"MySQL Boosting - DB Best Practices & Optimization" by José Luis Martínez - C..."MySQL Boosting - DB Best Practices & Optimization" by José Luis Martínez - C...
"MySQL Boosting - DB Best Practices & Optimization" by José Luis Martínez - C...
 
MySQL Performance Tips & Best Practices
MySQL Performance Tips & Best PracticesMySQL Performance Tips & Best Practices
MySQL Performance Tips & Best Practices
 
Performance Tuning And Optimization Microsoft SQL Database
Performance Tuning And Optimization Microsoft SQL DatabasePerformance Tuning And Optimization Microsoft SQL Database
Performance Tuning And Optimization Microsoft SQL Database
 
3 g huawei-wcdma-rno-parameters-optimization
3 g huawei-wcdma-rno-parameters-optimization3 g huawei-wcdma-rno-parameters-optimization
3 g huawei-wcdma-rno-parameters-optimization
 

Semelhante a Practical SQL query monitoring and optimization

Sql Server Performance Tuning
Sql Server Performance TuningSql Server Performance Tuning
Sql Server Performance TuningBala Subra
 
SQL Server - High availability
SQL Server - High availabilitySQL Server - High availability
SQL Server - High availabilityPeter Gfader
 
Novidades do SQL Server 2016
Novidades do SQL Server 2016Novidades do SQL Server 2016
Novidades do SQL Server 2016Marcos Freccia
 
Software Project Management - NESDEV
Software Project Management - NESDEVSoftware Project Management - NESDEV
Software Project Management - NESDEVKrit Kamtuo
 
Grant Fritchey - Query Tuning In Azure SQL Database
Grant Fritchey - Query Tuning In Azure SQL DatabaseGrant Fritchey - Query Tuning In Azure SQL Database
Grant Fritchey - Query Tuning In Azure SQL DatabaseRed Gate Software
 
Datastage Online Training @ Adithya Elearning
Datastage Online Training @ Adithya ElearningDatastage Online Training @ Adithya Elearning
Datastage Online Training @ Adithya Elearningshanmukha rao dondapati
 
AnalysisServices
AnalysisServicesAnalysisServices
AnalysisServiceswebuploader
 
Saying goodbye to SQL Server 2000
Saying goodbye to SQL Server 2000Saying goodbye to SQL Server 2000
Saying goodbye to SQL Server 2000ukdpe
 
The two faces of sql parameter sniffing
The two faces of sql parameter sniffingThe two faces of sql parameter sniffing
The two faces of sql parameter sniffingIvo Andreev
 
Query Store and live Query Statistics
Query Store and live Query StatisticsQuery Store and live Query Statistics
Query Store and live Query StatisticsSolidQ
 
Self-serve analytics journey at Celtra: Snowflake, Spark, and Databricks
Self-serve analytics journey at Celtra: Snowflake, Spark, and DatabricksSelf-serve analytics journey at Celtra: Snowflake, Spark, and Databricks
Self-serve analytics journey at Celtra: Snowflake, Spark, and DatabricksGrega Kespret
 
Expert summit SQL Server 2016
Expert summit   SQL Server 2016Expert summit   SQL Server 2016
Expert summit SQL Server 2016Łukasz Grala
 
Performance Tuning With Oracle ASH and AWR. Part 1 How And What
Performance Tuning With Oracle ASH and AWR. Part 1 How And WhatPerformance Tuning With Oracle ASH and AWR. Part 1 How And What
Performance Tuning With Oracle ASH and AWR. Part 1 How And Whatudaymoogala
 
DB Optimizer Datasheet - Automated SQL Profiling & Tuning for Optimized Perfo...
DB Optimizer Datasheet - Automated SQL Profiling & Tuning for Optimized Perfo...DB Optimizer Datasheet - Automated SQL Profiling & Tuning for Optimized Perfo...
DB Optimizer Datasheet - Automated SQL Profiling & Tuning for Optimized Perfo...Embarcadero Technologies
 
05_DP_300T00A_Optimize.pptx
05_DP_300T00A_Optimize.pptx05_DP_300T00A_Optimize.pptx
05_DP_300T00A_Optimize.pptxKareemBullard1
 
SQL Server 2000 Research Series - Architecture Overview
SQL Server 2000 Research Series - Architecture OverviewSQL Server 2000 Research Series - Architecture Overview
SQL Server 2000 Research Series - Architecture OverviewJerry Yang
 
Best practices for_large_oracle_apps_r12_implementations
Best practices for_large_oracle_apps_r12_implementationsBest practices for_large_oracle_apps_r12_implementations
Best practices for_large_oracle_apps_r12_implementationsAjith Narayanan
 
SQL Server 2008 for Developers
SQL Server 2008 for DevelopersSQL Server 2008 for Developers
SQL Server 2008 for Developersukdpe
 
MIS5101 WK10 Outcome Measures
MIS5101 WK10 Outcome MeasuresMIS5101 WK10 Outcome Measures
MIS5101 WK10 Outcome MeasuresSteven Johnson
 

Semelhante a Practical SQL query monitoring and optimization (20)

Sql Server Performance Tuning
Sql Server Performance TuningSql Server Performance Tuning
Sql Server Performance Tuning
 
SQL Server - High availability
SQL Server - High availabilitySQL Server - High availability
SQL Server - High availability
 
Novidades do SQL Server 2016
Novidades do SQL Server 2016Novidades do SQL Server 2016
Novidades do SQL Server 2016
 
Software Project Management - NESDEV
Software Project Management - NESDEVSoftware Project Management - NESDEV
Software Project Management - NESDEV
 
Grant Fritchey - Query Tuning In Azure SQL Database
Grant Fritchey - Query Tuning In Azure SQL DatabaseGrant Fritchey - Query Tuning In Azure SQL Database
Grant Fritchey - Query Tuning In Azure SQL Database
 
Datastage Online Training @ Adithya Elearning
Datastage Online Training @ Adithya ElearningDatastage Online Training @ Adithya Elearning
Datastage Online Training @ Adithya Elearning
 
AnalysisServices
AnalysisServicesAnalysisServices
AnalysisServices
 
Saying goodbye to SQL Server 2000
Saying goodbye to SQL Server 2000Saying goodbye to SQL Server 2000
Saying goodbye to SQL Server 2000
 
The two faces of sql parameter sniffing
The two faces of sql parameter sniffingThe two faces of sql parameter sniffing
The two faces of sql parameter sniffing
 
Query Store and live Query Statistics
Query Store and live Query StatisticsQuery Store and live Query Statistics
Query Store and live Query Statistics
 
Self-serve analytics journey at Celtra: Snowflake, Spark, and Databricks
Self-serve analytics journey at Celtra: Snowflake, Spark, and DatabricksSelf-serve analytics journey at Celtra: Snowflake, Spark, and Databricks
Self-serve analytics journey at Celtra: Snowflake, Spark, and Databricks
 
Expert summit SQL Server 2016
Expert summit   SQL Server 2016Expert summit   SQL Server 2016
Expert summit SQL Server 2016
 
Performance Tuning With Oracle ASH and AWR. Part 1 How And What
Performance Tuning With Oracle ASH and AWR. Part 1 How And WhatPerformance Tuning With Oracle ASH and AWR. Part 1 How And What
Performance Tuning With Oracle ASH and AWR. Part 1 How And What
 
DB Optimizer Datasheet - Automated SQL Profiling & Tuning for Optimized Perfo...
DB Optimizer Datasheet - Automated SQL Profiling & Tuning for Optimized Perfo...DB Optimizer Datasheet - Automated SQL Profiling & Tuning for Optimized Perfo...
DB Optimizer Datasheet - Automated SQL Profiling & Tuning for Optimized Perfo...
 
05_DP_300T00A_Optimize.pptx
05_DP_300T00A_Optimize.pptx05_DP_300T00A_Optimize.pptx
05_DP_300T00A_Optimize.pptx
 
SQL Server 2000 Research Series - Architecture Overview
SQL Server 2000 Research Series - Architecture OverviewSQL Server 2000 Research Series - Architecture Overview
SQL Server 2000 Research Series - Architecture Overview
 
Tfs Overview
Tfs OverviewTfs Overview
Tfs Overview
 
Best practices for_large_oracle_apps_r12_implementations
Best practices for_large_oracle_apps_r12_implementationsBest practices for_large_oracle_apps_r12_implementations
Best practices for_large_oracle_apps_r12_implementations
 
SQL Server 2008 for Developers
SQL Server 2008 for DevelopersSQL Server 2008 for Developers
SQL Server 2008 for Developers
 
MIS5101 WK10 Outcome Measures
MIS5101 WK10 Outcome MeasuresMIS5101 WK10 Outcome Measures
MIS5101 WK10 Outcome Measures
 

Mais de Ivo Andreev

Cybersecurity and Generative AI - for Good and Bad vol.2
Cybersecurity and Generative AI - for Good and Bad vol.2Cybersecurity and Generative AI - for Good and Bad vol.2
Cybersecurity and Generative AI - for Good and Bad vol.2Ivo Andreev
 
Architecting AI Solutions in Azure for Business
Architecting AI Solutions in Azure for BusinessArchitecting AI Solutions in Azure for Business
Architecting AI Solutions in Azure for BusinessIvo Andreev
 
Cybersecurity Challenges with Generative AI - for Good and Bad
Cybersecurity Challenges with Generative AI - for Good and BadCybersecurity Challenges with Generative AI - for Good and Bad
Cybersecurity Challenges with Generative AI - for Good and BadIvo Andreev
 
JS-Experts - Cybersecurity for Generative AI
JS-Experts - Cybersecurity for Generative AIJS-Experts - Cybersecurity for Generative AI
JS-Experts - Cybersecurity for Generative AIIvo Andreev
 
How do OpenAI GPT Models Work - Misconceptions and Tips for Developers
How do OpenAI GPT Models Work - Misconceptions and Tips for DevelopersHow do OpenAI GPT Models Work - Misconceptions and Tips for Developers
How do OpenAI GPT Models Work - Misconceptions and Tips for DevelopersIvo Andreev
 
OpenAI GPT in Depth - Questions and Misconceptions
OpenAI GPT in Depth - Questions and MisconceptionsOpenAI GPT in Depth - Questions and Misconceptions
OpenAI GPT in Depth - Questions and MisconceptionsIvo Andreev
 
Cutting Edge Computer Vision for Everyone
Cutting Edge Computer Vision for EveryoneCutting Edge Computer Vision for Everyone
Cutting Edge Computer Vision for EveryoneIvo Andreev
 
Collecting and Analysing Spaceborn Data
Collecting and Analysing Spaceborn DataCollecting and Analysing Spaceborn Data
Collecting and Analysing Spaceborn DataIvo Andreev
 
Collecting and Analysing Satellite Data with Azure Orbital
Collecting and Analysing Satellite Data with Azure OrbitalCollecting and Analysing Satellite Data with Azure Orbital
Collecting and Analysing Satellite Data with Azure OrbitalIvo Andreev
 
Language Studio and Custom Models
Language Studio and Custom ModelsLanguage Studio and Custom Models
Language Studio and Custom ModelsIvo Andreev
 
CosmosDB for IoT Scenarios
CosmosDB for IoT ScenariosCosmosDB for IoT Scenarios
CosmosDB for IoT ScenariosIvo Andreev
 
Forecasting time series powerful and simple
Forecasting time series powerful and simpleForecasting time series powerful and simple
Forecasting time series powerful and simpleIvo Andreev
 
Constrained Optimization with Genetic Algorithms and Project Bonsai
Constrained Optimization with Genetic Algorithms and Project BonsaiConstrained Optimization with Genetic Algorithms and Project Bonsai
Constrained Optimization with Genetic Algorithms and Project BonsaiIvo Andreev
 
Azure security guidelines for developers
Azure security guidelines for developers Azure security guidelines for developers
Azure security guidelines for developers Ivo Andreev
 
Autonomous Machines with Project Bonsai
Autonomous Machines with Project BonsaiAutonomous Machines with Project Bonsai
Autonomous Machines with Project BonsaiIvo Andreev
 
Global azure virtual 2021 - Azure Lighthouse
Global azure virtual 2021 - Azure LighthouseGlobal azure virtual 2021 - Azure Lighthouse
Global azure virtual 2021 - Azure LighthouseIvo Andreev
 
Flux QL - Nexgen Management of Time Series Inspired by JS
Flux QL - Nexgen Management of Time Series Inspired by JSFlux QL - Nexgen Management of Time Series Inspired by JS
Flux QL - Nexgen Management of Time Series Inspired by JSIvo Andreev
 
Azure architecture design patterns - proven solutions to common challenges
Azure architecture design patterns - proven solutions to common challengesAzure architecture design patterns - proven solutions to common challenges
Azure architecture design patterns - proven solutions to common challengesIvo Andreev
 
Industrial IoT on Azure
Industrial IoT on AzureIndustrial IoT on Azure
Industrial IoT on AzureIvo Andreev
 
The Power of Auto ML and How Does it Work
The Power of Auto ML and How Does it WorkThe Power of Auto ML and How Does it Work
The Power of Auto ML and How Does it WorkIvo Andreev
 

Mais de Ivo Andreev (20)

Cybersecurity and Generative AI - for Good and Bad vol.2
Cybersecurity and Generative AI - for Good and Bad vol.2Cybersecurity and Generative AI - for Good and Bad vol.2
Cybersecurity and Generative AI - for Good and Bad vol.2
 
Architecting AI Solutions in Azure for Business
Architecting AI Solutions in Azure for BusinessArchitecting AI Solutions in Azure for Business
Architecting AI Solutions in Azure for Business
 
Cybersecurity Challenges with Generative AI - for Good and Bad
Cybersecurity Challenges with Generative AI - for Good and BadCybersecurity Challenges with Generative AI - for Good and Bad
Cybersecurity Challenges with Generative AI - for Good and Bad
 
JS-Experts - Cybersecurity for Generative AI
JS-Experts - Cybersecurity for Generative AIJS-Experts - Cybersecurity for Generative AI
JS-Experts - Cybersecurity for Generative AI
 
How do OpenAI GPT Models Work - Misconceptions and Tips for Developers
How do OpenAI GPT Models Work - Misconceptions and Tips for DevelopersHow do OpenAI GPT Models Work - Misconceptions and Tips for Developers
How do OpenAI GPT Models Work - Misconceptions and Tips for Developers
 
OpenAI GPT in Depth - Questions and Misconceptions
OpenAI GPT in Depth - Questions and MisconceptionsOpenAI GPT in Depth - Questions and Misconceptions
OpenAI GPT in Depth - Questions and Misconceptions
 
Cutting Edge Computer Vision for Everyone
Cutting Edge Computer Vision for EveryoneCutting Edge Computer Vision for Everyone
Cutting Edge Computer Vision for Everyone
 
Collecting and Analysing Spaceborn Data
Collecting and Analysing Spaceborn DataCollecting and Analysing Spaceborn Data
Collecting and Analysing Spaceborn Data
 
Collecting and Analysing Satellite Data with Azure Orbital
Collecting and Analysing Satellite Data with Azure OrbitalCollecting and Analysing Satellite Data with Azure Orbital
Collecting and Analysing Satellite Data with Azure Orbital
 
Language Studio and Custom Models
Language Studio and Custom ModelsLanguage Studio and Custom Models
Language Studio and Custom Models
 
CosmosDB for IoT Scenarios
CosmosDB for IoT ScenariosCosmosDB for IoT Scenarios
CosmosDB for IoT Scenarios
 
Forecasting time series powerful and simple
Forecasting time series powerful and simpleForecasting time series powerful and simple
Forecasting time series powerful and simple
 
Constrained Optimization with Genetic Algorithms and Project Bonsai
Constrained Optimization with Genetic Algorithms and Project BonsaiConstrained Optimization with Genetic Algorithms and Project Bonsai
Constrained Optimization with Genetic Algorithms and Project Bonsai
 
Azure security guidelines for developers
Azure security guidelines for developers Azure security guidelines for developers
Azure security guidelines for developers
 
Autonomous Machines with Project Bonsai
Autonomous Machines with Project BonsaiAutonomous Machines with Project Bonsai
Autonomous Machines with Project Bonsai
 
Global azure virtual 2021 - Azure Lighthouse
Global azure virtual 2021 - Azure LighthouseGlobal azure virtual 2021 - Azure Lighthouse
Global azure virtual 2021 - Azure Lighthouse
 
Flux QL - Nexgen Management of Time Series Inspired by JS
Flux QL - Nexgen Management of Time Series Inspired by JSFlux QL - Nexgen Management of Time Series Inspired by JS
Flux QL - Nexgen Management of Time Series Inspired by JS
 
Azure architecture design patterns - proven solutions to common challenges
Azure architecture design patterns - proven solutions to common challengesAzure architecture design patterns - proven solutions to common challenges
Azure architecture design patterns - proven solutions to common challenges
 
Industrial IoT on Azure
Industrial IoT on AzureIndustrial IoT on Azure
Industrial IoT on Azure
 
The Power of Auto ML and How Does it Work
The Power of Auto ML and How Does it WorkThe Power of Auto ML and How Does it Work
The Power of Auto ML and How Does it Work
 

Último

Top profile Call Girls In dimapur [ 7014168258 ] Call Me For Genuine Models W...
Top profile Call Girls In dimapur [ 7014168258 ] Call Me For Genuine Models W...Top profile Call Girls In dimapur [ 7014168258 ] Call Me For Genuine Models W...
Top profile Call Girls In dimapur [ 7014168258 ] Call Me For Genuine Models W...gajnagarg
 
Top profile Call Girls In Begusarai [ 7014168258 ] Call Me For Genuine Models...
Top profile Call Girls In Begusarai [ 7014168258 ] Call Me For Genuine Models...Top profile Call Girls In Begusarai [ 7014168258 ] Call Me For Genuine Models...
Top profile Call Girls In Begusarai [ 7014168258 ] Call Me For Genuine Models...nirzagarg
 
TrafficWave Generator Will Instantly drive targeted and engaging traffic back...
TrafficWave Generator Will Instantly drive targeted and engaging traffic back...TrafficWave Generator Will Instantly drive targeted and engaging traffic back...
TrafficWave Generator Will Instantly drive targeted and engaging traffic back...SOFTTECHHUB
 
Sealdah % High Class Call Girls Kolkata - 450+ Call Girl Cash Payment 8005736...
Sealdah % High Class Call Girls Kolkata - 450+ Call Girl Cash Payment 8005736...Sealdah % High Class Call Girls Kolkata - 450+ Call Girl Cash Payment 8005736...
Sealdah % High Class Call Girls Kolkata - 450+ Call Girl Cash Payment 8005736...HyderabadDolls
 
Gulbai Tekra * Cheap Call Girls In Ahmedabad Phone No 8005736733 Elite Escort...
Gulbai Tekra * Cheap Call Girls In Ahmedabad Phone No 8005736733 Elite Escort...Gulbai Tekra * Cheap Call Girls In Ahmedabad Phone No 8005736733 Elite Escort...
Gulbai Tekra * Cheap Call Girls In Ahmedabad Phone No 8005736733 Elite Escort...gragchanchal546
 
7. Epi of Chronic respiratory diseases.ppt
7. Epi of Chronic respiratory diseases.ppt7. Epi of Chronic respiratory diseases.ppt
7. Epi of Chronic respiratory diseases.pptibrahimabdi22
 
Top profile Call Girls In Chandrapur [ 7014168258 ] Call Me For Genuine Model...
Top profile Call Girls In Chandrapur [ 7014168258 ] Call Me For Genuine Model...Top profile Call Girls In Chandrapur [ 7014168258 ] Call Me For Genuine Model...
Top profile Call Girls In Chandrapur [ 7014168258 ] Call Me For Genuine Model...gajnagarg
 
Discover Why Less is More in B2B Research
Discover Why Less is More in B2B ResearchDiscover Why Less is More in B2B Research
Discover Why Less is More in B2B Researchmichael115558
 
Reconciling Conflicting Data Curation Actions: Transparency Through Argument...
Reconciling Conflicting Data Curation Actions:  Transparency Through Argument...Reconciling Conflicting Data Curation Actions:  Transparency Through Argument...
Reconciling Conflicting Data Curation Actions: Transparency Through Argument...Bertram Ludäscher
 
High Profile Call Girls Service in Jalore { 9332606886 } VVIP NISHA Call Girl...
High Profile Call Girls Service in Jalore { 9332606886 } VVIP NISHA Call Girl...High Profile Call Girls Service in Jalore { 9332606886 } VVIP NISHA Call Girl...
High Profile Call Girls Service in Jalore { 9332606886 } VVIP NISHA Call Girl...kumargunjan9515
 
In Riyadh ((+919101817206)) Cytotec kit @ Abortion Pills Saudi Arabia
In Riyadh ((+919101817206)) Cytotec kit @ Abortion Pills Saudi ArabiaIn Riyadh ((+919101817206)) Cytotec kit @ Abortion Pills Saudi Arabia
In Riyadh ((+919101817206)) Cytotec kit @ Abortion Pills Saudi Arabiaahmedjiabur940
 
5CL-ADBA,5cladba, Chinese supplier, safety is guaranteed
5CL-ADBA,5cladba, Chinese supplier, safety is guaranteed5CL-ADBA,5cladba, Chinese supplier, safety is guaranteed
5CL-ADBA,5cladba, Chinese supplier, safety is guaranteedamy56318795
 
Nirala Nagar / Cheap Call Girls In Lucknow Phone No 9548273370 Elite Escort S...
Nirala Nagar / Cheap Call Girls In Lucknow Phone No 9548273370 Elite Escort S...Nirala Nagar / Cheap Call Girls In Lucknow Phone No 9548273370 Elite Escort S...
Nirala Nagar / Cheap Call Girls In Lucknow Phone No 9548273370 Elite Escort S...HyderabadDolls
 
DATA SUMMIT 24 Building Real-Time Pipelines With FLaNK
DATA SUMMIT 24  Building Real-Time Pipelines With FLaNKDATA SUMMIT 24  Building Real-Time Pipelines With FLaNK
DATA SUMMIT 24 Building Real-Time Pipelines With FLaNKTimothy Spann
 
Fun all Day Call Girls in Jaipur 9332606886 High Profile Call Girls You Ca...
Fun all Day Call Girls in Jaipur   9332606886  High Profile Call Girls You Ca...Fun all Day Call Girls in Jaipur   9332606886  High Profile Call Girls You Ca...
Fun all Day Call Girls in Jaipur 9332606886 High Profile Call Girls You Ca...kumargunjan9515
 
Top profile Call Girls In Latur [ 7014168258 ] Call Me For Genuine Models We ...
Top profile Call Girls In Latur [ 7014168258 ] Call Me For Genuine Models We ...Top profile Call Girls In Latur [ 7014168258 ] Call Me For Genuine Models We ...
Top profile Call Girls In Latur [ 7014168258 ] Call Me For Genuine Models We ...gajnagarg
 
如何办理英国诺森比亚大学毕业证(NU毕业证书)成绩单原件一模一样
如何办理英国诺森比亚大学毕业证(NU毕业证书)成绩单原件一模一样如何办理英国诺森比亚大学毕业证(NU毕业证书)成绩单原件一模一样
如何办理英国诺森比亚大学毕业证(NU毕业证书)成绩单原件一模一样wsppdmt
 
Lecture_2_Deep_Learning_Overview-newone1
Lecture_2_Deep_Learning_Overview-newone1Lecture_2_Deep_Learning_Overview-newone1
Lecture_2_Deep_Learning_Overview-newone1ranjankumarbehera14
 
Aspirational Block Program Block Syaldey District - Almora
Aspirational Block Program Block Syaldey District - AlmoraAspirational Block Program Block Syaldey District - Almora
Aspirational Block Program Block Syaldey District - AlmoraGovindSinghDasila
 
Dubai Call Girls Peeing O525547819 Call Girls Dubai
Dubai Call Girls Peeing O525547819 Call Girls DubaiDubai Call Girls Peeing O525547819 Call Girls Dubai
Dubai Call Girls Peeing O525547819 Call Girls Dubaikojalkojal131
 

Último (20)

Top profile Call Girls In dimapur [ 7014168258 ] Call Me For Genuine Models W...
Top profile Call Girls In dimapur [ 7014168258 ] Call Me For Genuine Models W...Top profile Call Girls In dimapur [ 7014168258 ] Call Me For Genuine Models W...
Top profile Call Girls In dimapur [ 7014168258 ] Call Me For Genuine Models W...
 
Top profile Call Girls In Begusarai [ 7014168258 ] Call Me For Genuine Models...
Top profile Call Girls In Begusarai [ 7014168258 ] Call Me For Genuine Models...Top profile Call Girls In Begusarai [ 7014168258 ] Call Me For Genuine Models...
Top profile Call Girls In Begusarai [ 7014168258 ] Call Me For Genuine Models...
 
TrafficWave Generator Will Instantly drive targeted and engaging traffic back...
TrafficWave Generator Will Instantly drive targeted and engaging traffic back...TrafficWave Generator Will Instantly drive targeted and engaging traffic back...
TrafficWave Generator Will Instantly drive targeted and engaging traffic back...
 
Sealdah % High Class Call Girls Kolkata - 450+ Call Girl Cash Payment 8005736...
Sealdah % High Class Call Girls Kolkata - 450+ Call Girl Cash Payment 8005736...Sealdah % High Class Call Girls Kolkata - 450+ Call Girl Cash Payment 8005736...
Sealdah % High Class Call Girls Kolkata - 450+ Call Girl Cash Payment 8005736...
 
Gulbai Tekra * Cheap Call Girls In Ahmedabad Phone No 8005736733 Elite Escort...
Gulbai Tekra * Cheap Call Girls In Ahmedabad Phone No 8005736733 Elite Escort...Gulbai Tekra * Cheap Call Girls In Ahmedabad Phone No 8005736733 Elite Escort...
Gulbai Tekra * Cheap Call Girls In Ahmedabad Phone No 8005736733 Elite Escort...
 
7. Epi of Chronic respiratory diseases.ppt
7. Epi of Chronic respiratory diseases.ppt7. Epi of Chronic respiratory diseases.ppt
7. Epi of Chronic respiratory diseases.ppt
 
Top profile Call Girls In Chandrapur [ 7014168258 ] Call Me For Genuine Model...
Top profile Call Girls In Chandrapur [ 7014168258 ] Call Me For Genuine Model...Top profile Call Girls In Chandrapur [ 7014168258 ] Call Me For Genuine Model...
Top profile Call Girls In Chandrapur [ 7014168258 ] Call Me For Genuine Model...
 
Discover Why Less is More in B2B Research
Discover Why Less is More in B2B ResearchDiscover Why Less is More in B2B Research
Discover Why Less is More in B2B Research
 
Reconciling Conflicting Data Curation Actions: Transparency Through Argument...
Reconciling Conflicting Data Curation Actions:  Transparency Through Argument...Reconciling Conflicting Data Curation Actions:  Transparency Through Argument...
Reconciling Conflicting Data Curation Actions: Transparency Through Argument...
 
High Profile Call Girls Service in Jalore { 9332606886 } VVIP NISHA Call Girl...
High Profile Call Girls Service in Jalore { 9332606886 } VVIP NISHA Call Girl...High Profile Call Girls Service in Jalore { 9332606886 } VVIP NISHA Call Girl...
High Profile Call Girls Service in Jalore { 9332606886 } VVIP NISHA Call Girl...
 
In Riyadh ((+919101817206)) Cytotec kit @ Abortion Pills Saudi Arabia
In Riyadh ((+919101817206)) Cytotec kit @ Abortion Pills Saudi ArabiaIn Riyadh ((+919101817206)) Cytotec kit @ Abortion Pills Saudi Arabia
In Riyadh ((+919101817206)) Cytotec kit @ Abortion Pills Saudi Arabia
 
5CL-ADBA,5cladba, Chinese supplier, safety is guaranteed
5CL-ADBA,5cladba, Chinese supplier, safety is guaranteed5CL-ADBA,5cladba, Chinese supplier, safety is guaranteed
5CL-ADBA,5cladba, Chinese supplier, safety is guaranteed
 
Nirala Nagar / Cheap Call Girls In Lucknow Phone No 9548273370 Elite Escort S...
Nirala Nagar / Cheap Call Girls In Lucknow Phone No 9548273370 Elite Escort S...Nirala Nagar / Cheap Call Girls In Lucknow Phone No 9548273370 Elite Escort S...
Nirala Nagar / Cheap Call Girls In Lucknow Phone No 9548273370 Elite Escort S...
 
DATA SUMMIT 24 Building Real-Time Pipelines With FLaNK
DATA SUMMIT 24  Building Real-Time Pipelines With FLaNKDATA SUMMIT 24  Building Real-Time Pipelines With FLaNK
DATA SUMMIT 24 Building Real-Time Pipelines With FLaNK
 
Fun all Day Call Girls in Jaipur 9332606886 High Profile Call Girls You Ca...
Fun all Day Call Girls in Jaipur   9332606886  High Profile Call Girls You Ca...Fun all Day Call Girls in Jaipur   9332606886  High Profile Call Girls You Ca...
Fun all Day Call Girls in Jaipur 9332606886 High Profile Call Girls You Ca...
 
Top profile Call Girls In Latur [ 7014168258 ] Call Me For Genuine Models We ...
Top profile Call Girls In Latur [ 7014168258 ] Call Me For Genuine Models We ...Top profile Call Girls In Latur [ 7014168258 ] Call Me For Genuine Models We ...
Top profile Call Girls In Latur [ 7014168258 ] Call Me For Genuine Models We ...
 
如何办理英国诺森比亚大学毕业证(NU毕业证书)成绩单原件一模一样
如何办理英国诺森比亚大学毕业证(NU毕业证书)成绩单原件一模一样如何办理英国诺森比亚大学毕业证(NU毕业证书)成绩单原件一模一样
如何办理英国诺森比亚大学毕业证(NU毕业证书)成绩单原件一模一样
 
Lecture_2_Deep_Learning_Overview-newone1
Lecture_2_Deep_Learning_Overview-newone1Lecture_2_Deep_Learning_Overview-newone1
Lecture_2_Deep_Learning_Overview-newone1
 
Aspirational Block Program Block Syaldey District - Almora
Aspirational Block Program Block Syaldey District - AlmoraAspirational Block Program Block Syaldey District - Almora
Aspirational Block Program Block Syaldey District - Almora
 
Dubai Call Girls Peeing O525547819 Call Girls Dubai
Dubai Call Girls Peeing O525547819 Call Girls DubaiDubai Call Girls Peeing O525547819 Call Girls Dubai
Dubai Call Girls Peeing O525547819 Call Girls Dubai
 

Practical SQL query monitoring and optimization

  • 1. Practical SQL Query Monitoring and Optimization Identify Data Layer Bottlenecks
  • 2. About me Project Manager @ 10 years professional experience Microsoft Certified Specialist ivelin.andreev@icb.bg http://www.linkedin.com/in/ivelin Business Interests ASP.NET, AJAX, jQuery SOA, Integration GIS, Mapping SQL optimization 2 |
  • 3. A Well Known Story Monitor and Measure Application Analyze Tier Interaction Getting Performance Hints Identify Problematic Queries Optimization Query Performance Measure the Effect Maintain 3 |
  • 4. Warning: A Bottleneck Visual Studio Performance Wizard CPU and Memory Sampling Concurrency Tier Interaction SQL Server Profiler Create trace Analyze trace results Replay trace Log analyzer Most frequent and timely queries Identify long-running locks (and deadlocks) Identify I/O activity SQL Solutions Trace Analyzer / Deadlock Detector
  • 5. Row vs. Chunk at a Time Row at a time (RAT) processing SELECT * FROM Activities WHERE ParentId = 1 SELECT * FROM Activities WHERE ParentId = 2 SELECT * FROM Activities WHERE ParentId = 16 Chunk at a time (CAT) processing SELECT * FROM Activities WHERE ParentId IN (1,2,16) Likely to happen when: Components with own DataSource extraction Complex code by different developers
  • 6. DEMO 1 Row vs. Chunk at a Time Analyzing Trace Logs
  • 7. Getting Help Analyze Execution Plan Database Tuning Advisor Suggests indexes and statistics Opt.1: Improvement 20% Opt.2: Improvement 20% Dynamic Management Views Missing Indexes (sys.dm_db_missing_index_groups) Slowest Queries (sys.dm_exec_query_stats)
  • 8. DEMO 2 Tuning Advisor Dynamic Management Views
  • 9. Analyze Query Plan Tools SQL Server Management Studio SQL Sentry: free @ http://www.sqlsentry.com Query Plan Colour-scaled cost information Cost filter by CPU, I/O or both Better plan layout Top Operations Tuning Tips
  • 10. Query Plan Basics Table Scan (Heap) Clustered index missing Scans data pages (all data) Index Scan Scans index pages (less data) Relies on order of pages Index Seek Highly selective queries (10-15% of rows) Indexed Views Require: Schema binding Require: Deterministic functions
  • 11. DEMO 3 Query Plan Explorer OR vs. UNION
  • 12. Indexes Index types Clustered / Non-clustered Filtered index(SQL 2008) Covering index Objective Optimal performance Reduce slow scans Difference in large data sets
  • 13. Are Indexes Magical ? Choosing Indexes Measure query impact Measure index size Maintenance Fragmentation = poor disk I/O Reorganize vs. Rebuild Automate: Nightly Job Anti-patterns Create indexes blindly Execute non-indexable queries SELECT * FROM Employees WHERE CAST(PNumber AS INT) 1 SELECT * FROM Customers WHERE ContactName LIKE ‘%a%’ SELECT * FROM Employees WHERE FName=‘a’ OR LName=‘b’ Reject indexes because of their overhead
  • 14. SQL Server Statistics Objective WHERE clause order Statistics on data distribution Query Optimizer creates efficient plan Up-to-date check Automatically created for index keys Estimated vs. Actual Rows Maintenance DB Default: AUTOCREATE and AUTOUPDATE EXEC sp_updatestats Automate: Nightly Job
  • 15. User Defined Functions Procedures vs. Functions Performance vs. Reusability Complex conditions Used through the whole application i.e. IsCaseClosed Chunk at a Time Table valued parameters (SQL 2008 and on) Pass result from one function to next
  • 16. Optimize Locks Data Integrity Data commit waits NOLOCK Prevent Deadlocks Returns uncommitted data Incorrect results Less/More rows could be returned Update one entity, retrieve another Index page splits under heavy load(GUID)
  • 17. DEMO 4 The NOLOCK Problem
  • 18. Common Table Expressions (CTE) Alias of a query (SQL 2005) Advantages Readability and reusability Implement recursive query Materializes when used Uses indexes (Table v@r not) Disadvantages Can be used only once Must be used immediately
  • 19. Other UNION vs. UNION ALL Data Types Do you really need BIGINT? Requires storage Requires time to read Requires memory BIGINT INT Delta (MB) Delta (%) Primary Key 1267 977 290 23% By_PropID_CountryID 813 741 72 9% By_String 303 230 73 24%
  • 20. SQL Resource Governor Shared DB Server Prioritize queries Reporting vs. Dashboard Memory, CPU Connections, Parallelism RG Configuration Pools Workload Groups Custom classification function Available in SQL Server Enterprise
  • 21. Test Under Load Life’s complicated Concurrent queries Multiple user Cached Buffers Tools SQL Server Profiler Replay SQL Server 2012 Distributed Replay Snap In @ http://dreplaygui.codeplex.com/ SQL Load Generator http://sqlloadgenerator.codeplex.com/
  • 22. Summary Steps Capture/Analysis/Optimization Measure the improvement Maintain Remember Reoccurring improvement Ideally you should analyze all SQL Changes can affect SQL performance in data size result set size
  • 23. DEMO 5 Trace Replay SQL Load Generator Resource Governor
  • 24. Other Approaches Caching Application (Static) Session Context WCF Session Entity Framework Caching Paging Lazy loading Parallel binding Historical / Live data tables
  • 25. SQL Saturday #152 Sponsors