SlideShare uma empresa Scribd logo
1 de 23
SQL Server 2008 Development for Programmers(Level 200) Springfield .NET Users Group June 28th, 2011 Presentation by Adam Hutson
Speaker Bio – Adam Hutson Database Developer at Expedia and a freelance developer.   11 year career, mostly on software side, on database side for past couple years.   Enjoy learning new development techniques, earning MSSQL certifications, and picking up various web & desktop development side projects.  Married 8 yrs & 4 kiddos (B-6y, G-4y, G-2y, & G-5m) Blog: http://adamhutson.com/LinkedIn: http://www.linkedin.com/in/adamhutson
Presentation Overview Review of CRUD & JOIN basics Dynamic vs. Compiled Statements Indexes & Execution Plans Performance Issues Scaling up your Database Personal toolbox, templates, & links
CRUD basics Create  INSERT statementsINSERTMyTable(Col1, Col2)VALUES ('a','b') Read  SELECT statementsSELECT Col1, Col2 FROMMyTable Update  UPDATE statementsUPDATE MyTable SET Col1 = Col1 + Col1 Delete  DELETE statementsDELETEFROMMyTableWHERE Col2 ='b'
JOIN basics [INNER] JOIN LEFT [OUTER] JOIN RIGHT [OUTER] JOIN FULL [OUTER] JOIN CROSS JOIN
[INNER] JOIN INNER Joins combine the matching records from 2 tables.  INNER keyword is optional.
LEFT [OUTER] JOIN LEFT [OUTER] JOINs combine all the records from the left table and only the matching records from right table.  OUTER keyword is optional.
RIGHT [OUTER] JOIN RIGHT [OUTER] JOINs combine all the records from the right table and only the matching records from left table.  OUTER keyword is optional.
FULL [OUTER] JOIN FULL [OUTER] JOINs combine all rows from both tables regardless of match.  OUTER keyword is optional.
CROSS JOIN CROSS JOINs provide a Cartesian product between two tables.  A Cartesian product contains all the rows from all the tables combined.
Dynamic vs. Compiled Statements Dynamic SQL Statements Constructed at runtime with variable data Execution plan is determined on 1stexecution Any adhoc query is dynamic to the optimizer Compiled SQL Statements Constructed at design time Execution plan is known before execution Stored Procedures are compiled
Execution Plans What is an execution plan? Query optimizer’s attempt to calculate the most efficient way to implement a query. Calculates the cost in terms of CPU, I/O, & speed. Where are they stored? Generating an execution plan is expensive, so they are stored for reuse in memory (plan cache). Are purged from memory using an aging formula that considers it’s cost and use
Indexes What are indexes? Catalog of locations and order of records in table Why use them? Speeds up queries; tables are just heaps of data without them Types: Clustered  NonClustered Composite Unique Covering
Index storage An index is a set of pages (index nodes) that are organized in a B-tree structure. Root Level IntermediateLevels Leaf Level
Clustered – stores the actual data rows at the leaf level of the index; physically sorted table; only 1 per table NonClustered – leaf nodes contain only the values from the indexed columns and row locators to the actual data rows, not the actual data rows themselves; 249 per table Composite – contains more than one column  up to 16; can be clustered or nonclustered; max of 900 bytes Unique – ensures each value in the indexed column is unique.  If composite, then the uniqueness is enforced across the columns as a whole. Defining a PK or unique constraint automatically creates a Unique index Covering – includes all the columns that are needed to process a query; an extension of nonclustered functionality; adds non-key columns to the leaf level; not included when calculating number of index key columns or index key size.
If a table’s data changes frequently, keep indexes few, simple, & narrow. For tables with a lot of data and infrequent changes, use as many indexes as needed for performance. Create nonclustered indexes on columns used frequently in predicates and join conditions. Index columns with exact match queries. Don’t index small tables, a Table scan is quicker Try to keep predicate order the same as index order Periodically check DMVs for usage and for unused or missing indexes (sys.dm_db_index_usage_stats & sys.dm_db_missing_index_*)
Performance Issues Possible causes Blocking CPU Bottlenecks  Memory Bottlenecks  I/O Bottlenecks  Tools to Identify Performance Monitor (PerfMon) SQL Server Profiler  DBCC commands DMVs
Blocking Blocking is primarily waits for logical locks, which occur when a request to acquire  a non-compatible lock on an already-locked resource is made. Identifying: DMVs: sys.dm_os_wait*, sys.dm_tran_locks Profiler: Deadlock graph & Blocked process report
CPU Bottlenecks Can be caused by insufficient hardware, poor query tuning, or excessive query compilation. Identifying: PerfMon – “%Processor Time” > 80%, ratio of “SQL Recompilations / sec” to “Batch Requests / sec” be low Profiler – watch SP:Recompile & SQL:StmtRecompile classes DMVs – sys.dm_exec_query_stats & sys.dm_exec_query_optimizer_info
Memory Bottlenecks Low memory conditions, or memory pressure Use of AWE & VAS, actual physical memory, other applications Identifying: Task Manager Performance Monitor – “Memory: Available”, “Process: Working Set”, “Paging File:*” DMVs – sys.dm_os_memory_* DBCC MEMORYSTATUS
I/O Bottlenecks Check memory first as it can cause I/O Check execution plans for high I/O Identifying: PerfMon – Avg Disk Queue, Avg Disk Sec/Read, Avg Disk Sec/Write, %Disk Time, Avg Disc Reads/Sec, Avg Disk Writes/Sec DMVs – sys.dm_io_* & sys.dm_os_wait_stats where wait_type like 'PAGEIOLATCH%'
Scaling it all up Single database design isn’t appropriate here Designs have to incorporate multiple databases over multiple servers with different characteristics Transactional & Analytical needs are different Indexing strategies are different Execution plans should be scrutinized Partitioning  becomes pertinent as current and archive data coexist
Personal toolbox, templates, & links Watch my website and blog, I’ll post my toolbox of scripts, templates I use for object maintenance, and all the links I keep handy for referencing SQL topics. http://adamhutson.com

Mais conteúdo relacionado

Mais procurados

New fordevelopersinsql server2008
New fordevelopersinsql server2008New fordevelopersinsql server2008
New fordevelopersinsql server2008Aaron Shilo
 
SQL Server Query Optimization, Execution and Debugging Query Performance
SQL Server Query Optimization, Execution and Debugging Query PerformanceSQL Server Query Optimization, Execution and Debugging Query Performance
SQL Server Query Optimization, Execution and Debugging Query PerformanceVinod Kumar
 
Sql server introduction
Sql server introductionSql server introduction
Sql server introductionRiteshkiit
 
MySQL & Expression Engine EEUK2013
MySQL & Expression Engine EEUK2013MySQL & Expression Engine EEUK2013
MySQL & Expression Engine EEUK2013EEvolutionUK
 
Less13 Performance
Less13 PerformanceLess13 Performance
Less13 Performancevivaankumar
 
Hyperion essbase basics
Hyperion essbase basicsHyperion essbase basics
Hyperion essbase basicsAmit Sharma
 
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
 
Calculation commands in essbase
Calculation commands in essbaseCalculation commands in essbase
Calculation commands in essbaseShoheb Mohammad
 
Getting to know oracle database objects iot, mviews, clusters and more…
Getting to know oracle database objects iot, mviews, clusters and more…Getting to know oracle database objects iot, mviews, clusters and more…
Getting to know oracle database objects iot, mviews, clusters and more…Aaron Shilo
 
Large scale sql server best practices
Large scale sql server   best practicesLarge scale sql server   best practices
Large scale sql server best practicesmprabhuram
 
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
 
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
 
Brad McGehee Intepreting Execution Plans Mar09
Brad McGehee Intepreting Execution Plans Mar09Brad McGehee Intepreting Execution Plans Mar09
Brad McGehee Intepreting Execution Plans Mar09guest9d79e073
 
Uncovering SQL Server query problems with execution plans - Tony Davis
Uncovering SQL Server query problems with execution plans - Tony DavisUncovering SQL Server query problems with execution plans - Tony Davis
Uncovering SQL Server query problems with execution plans - Tony DavisRed Gate Software
 
resource governor
resource governorresource governor
resource governorAaron Shilo
 
Oracle performance tuning_sfsf
Oracle performance tuning_sfsfOracle performance tuning_sfsf
Oracle performance tuning_sfsfMao Geng
 
SQL Server Tuning to Improve Database Performance
SQL Server Tuning to Improve Database PerformanceSQL Server Tuning to Improve Database Performance
SQL Server Tuning to Improve Database PerformanceMark Ginnebaugh
 

Mais procurados (20)

New fordevelopersinsql server2008
New fordevelopersinsql server2008New fordevelopersinsql server2008
New fordevelopersinsql server2008
 
SQL Server Query Optimization, Execution and Debugging Query Performance
SQL Server Query Optimization, Execution and Debugging Query PerformanceSQL Server Query Optimization, Execution and Debugging Query Performance
SQL Server Query Optimization, Execution and Debugging Query Performance
 
Sql server introduction
Sql server introductionSql server introduction
Sql server introduction
 
MySQL & Expression Engine EEUK2013
MySQL & Expression Engine EEUK2013MySQL & Expression Engine EEUK2013
MySQL & Expression Engine EEUK2013
 
Performance tuning in sql server
Performance tuning in sql serverPerformance tuning in sql server
Performance tuning in sql server
 
Less13 Performance
Less13 PerformanceLess13 Performance
Less13 Performance
 
Hyperion essbase basics
Hyperion essbase basicsHyperion essbase basics
Hyperion essbase basics
 
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...
 
Calculation commands in essbase
Calculation commands in essbaseCalculation commands in essbase
Calculation commands in essbase
 
Getting to know oracle database objects iot, mviews, clusters and more…
Getting to know oracle database objects iot, mviews, clusters and more…Getting to know oracle database objects iot, mviews, clusters and more…
Getting to know oracle database objects iot, mviews, clusters and more…
 
Large scale sql server best practices
Large scale sql server   best practicesLarge scale sql server   best practices
Large scale sql server best practices
 
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
 
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
 
Weblogic plug in
Weblogic plug inWeblogic plug in
Weblogic plug in
 
SQLDay2013_MarcinSzeliga_StoredProcedures
SQLDay2013_MarcinSzeliga_StoredProceduresSQLDay2013_MarcinSzeliga_StoredProcedures
SQLDay2013_MarcinSzeliga_StoredProcedures
 
Brad McGehee Intepreting Execution Plans Mar09
Brad McGehee Intepreting Execution Plans Mar09Brad McGehee Intepreting Execution Plans Mar09
Brad McGehee Intepreting Execution Plans Mar09
 
Uncovering SQL Server query problems with execution plans - Tony Davis
Uncovering SQL Server query problems with execution plans - Tony DavisUncovering SQL Server query problems with execution plans - Tony Davis
Uncovering SQL Server query problems with execution plans - Tony Davis
 
resource governor
resource governorresource governor
resource governor
 
Oracle performance tuning_sfsf
Oracle performance tuning_sfsfOracle performance tuning_sfsf
Oracle performance tuning_sfsf
 
SQL Server Tuning to Improve Database Performance
SQL Server Tuning to Improve Database PerformanceSQL Server Tuning to Improve Database Performance
SQL Server Tuning to Improve Database Performance
 

Destaque

Alternatives to Relational Databases
Alternatives to Relational DatabasesAlternatives to Relational Databases
Alternatives to Relational DatabasesAdam Hutson
 
Cassandra Summit: Data Modeling A Scheduling App
Cassandra Summit: Data Modeling A Scheduling AppCassandra Summit: Data Modeling A Scheduling App
Cassandra Summit: Data Modeling A Scheduling AppAdam Hutson
 
SaaS Enablement Challenges & Approaches
SaaS Enablement Challenges & ApproachesSaaS Enablement Challenges & Approaches
SaaS Enablement Challenges & ApproachesImpetus Technologies
 
Data Modeling with Cassandra and Time Series Data
Data Modeling with Cassandra and Time Series DataData Modeling with Cassandra and Time Series Data
Data Modeling with Cassandra and Time Series DataDani Traphagen
 
Cassandra Summit 2015 - Building a multi-tenant API PaaS with DataStax Enterp...
Cassandra Summit 2015 - Building a multi-tenant API PaaS with DataStax Enterp...Cassandra Summit 2015 - Building a multi-tenant API PaaS with DataStax Enterp...
Cassandra Summit 2015 - Building a multi-tenant API PaaS with DataStax Enterp...Restlet
 
Wayne State University & DataStax: World's best data modeling tool for Apache...
Wayne State University & DataStax: World's best data modeling tool for Apache...Wayne State University & DataStax: World's best data modeling tool for Apache...
Wayne State University & DataStax: World's best data modeling tool for Apache...DataStax Academy
 
Data Modeling a Scheduling App (Adam Hutson, DataScale) | Cassandra Summit 2016
Data Modeling a Scheduling App (Adam Hutson, DataScale) | Cassandra Summit 2016Data Modeling a Scheduling App (Adam Hutson, DataScale) | Cassandra Summit 2016
Data Modeling a Scheduling App (Adam Hutson, DataScale) | Cassandra Summit 2016DataStax
 
Time series with Apache Cassandra - Long version
Time series with Apache Cassandra - Long versionTime series with Apache Cassandra - Long version
Time series with Apache Cassandra - Long versionPatrick McFadin
 
What We Learned About Cassandra While Building go90 (Christopher Webster & Th...
What We Learned About Cassandra While Building go90 (Christopher Webster & Th...What We Learned About Cassandra While Building go90 (Christopher Webster & Th...
What We Learned About Cassandra While Building go90 (Christopher Webster & Th...DataStax
 
Cassandra By Example: Data Modelling with CQL3
Cassandra By Example: Data Modelling with CQL3Cassandra By Example: Data Modelling with CQL3
Cassandra By Example: Data Modelling with CQL3Eric Evans
 
Cassandra Explained
Cassandra ExplainedCassandra Explained
Cassandra ExplainedEric Evans
 
Sint. proteínas
Sint. proteínasSint. proteínas
Sint. proteínasRoma29
 
3er parcial anahuac
3er parcial anahuac3er parcial anahuac
3er parcial anahuacRoma29
 
Resum Curs 2011 - 2012. Segona Part
Resum Curs 2011 - 2012. Segona PartResum Curs 2011 - 2012. Segona Part
Resum Curs 2011 - 2012. Segona PartOliverasqv
 
Budgetirovanie v 1 c 1
Budgetirovanie v 1 c 1Budgetirovanie v 1 c 1
Budgetirovanie v 1 c 1Razdolie73
 
“Seguridad efectiva” Mikel Uriarte de Nextel S.A.
“Seguridad efectiva” Mikel Uriarte de Nextel S.A.“Seguridad efectiva” Mikel Uriarte de Nextel S.A.
“Seguridad efectiva” Mikel Uriarte de Nextel S.A.Nextel S.A.
 

Destaque (20)

Alternatives to Relational Databases
Alternatives to Relational DatabasesAlternatives to Relational Databases
Alternatives to Relational Databases
 
Cassandra Summit: Data Modeling A Scheduling App
Cassandra Summit: Data Modeling A Scheduling AppCassandra Summit: Data Modeling A Scheduling App
Cassandra Summit: Data Modeling A Scheduling App
 
SaaS Enablement Challenges & Approaches
SaaS Enablement Challenges & ApproachesSaaS Enablement Challenges & Approaches
SaaS Enablement Challenges & Approaches
 
Data Modeling with Cassandra and Time Series Data
Data Modeling with Cassandra and Time Series DataData Modeling with Cassandra and Time Series Data
Data Modeling with Cassandra and Time Series Data
 
Cassandra Summit 2015 - Building a multi-tenant API PaaS with DataStax Enterp...
Cassandra Summit 2015 - Building a multi-tenant API PaaS with DataStax Enterp...Cassandra Summit 2015 - Building a multi-tenant API PaaS with DataStax Enterp...
Cassandra Summit 2015 - Building a multi-tenant API PaaS with DataStax Enterp...
 
Wayne State University & DataStax: World's best data modeling tool for Apache...
Wayne State University & DataStax: World's best data modeling tool for Apache...Wayne State University & DataStax: World's best data modeling tool for Apache...
Wayne State University & DataStax: World's best data modeling tool for Apache...
 
Data Modeling a Scheduling App (Adam Hutson, DataScale) | Cassandra Summit 2016
Data Modeling a Scheduling App (Adam Hutson, DataScale) | Cassandra Summit 2016Data Modeling a Scheduling App (Adam Hutson, DataScale) | Cassandra Summit 2016
Data Modeling a Scheduling App (Adam Hutson, DataScale) | Cassandra Summit 2016
 
Time series with Apache Cassandra - Long version
Time series with Apache Cassandra - Long versionTime series with Apache Cassandra - Long version
Time series with Apache Cassandra - Long version
 
What We Learned About Cassandra While Building go90 (Christopher Webster & Th...
What We Learned About Cassandra While Building go90 (Christopher Webster & Th...What We Learned About Cassandra While Building go90 (Christopher Webster & Th...
What We Learned About Cassandra While Building go90 (Christopher Webster & Th...
 
Cassandra By Example: Data Modelling with CQL3
Cassandra By Example: Data Modelling with CQL3Cassandra By Example: Data Modelling with CQL3
Cassandra By Example: Data Modelling with CQL3
 
Cassandra Explained
Cassandra ExplainedCassandra Explained
Cassandra Explained
 
Sitting the Key Features Examination
Sitting the Key Features ExaminationSitting the Key Features Examination
Sitting the Key Features Examination
 
HMI/UI Development Services - Bangalore, India
HMI/UI Development Services - Bangalore, IndiaHMI/UI Development Services - Bangalore, India
HMI/UI Development Services - Bangalore, India
 
Isaac slide show
Isaac slide showIsaac slide show
Isaac slide show
 
Sint. proteínas
Sint. proteínasSint. proteínas
Sint. proteínas
 
3er parcial anahuac
3er parcial anahuac3er parcial anahuac
3er parcial anahuac
 
Resum Curs 2011 - 2012. Segona Part
Resum Curs 2011 - 2012. Segona PartResum Curs 2011 - 2012. Segona Part
Resum Curs 2011 - 2012. Segona Part
 
Goazen kirofanora
Goazen kirofanoraGoazen kirofanora
Goazen kirofanora
 
Budgetirovanie v 1 c 1
Budgetirovanie v 1 c 1Budgetirovanie v 1 c 1
Budgetirovanie v 1 c 1
 
“Seguridad efectiva” Mikel Uriarte de Nextel S.A.
“Seguridad efectiva” Mikel Uriarte de Nextel S.A.“Seguridad efectiva” Mikel Uriarte de Nextel S.A.
“Seguridad efectiva” Mikel Uriarte de Nextel S.A.
 

Semelhante a SQL Server 2008 Development for Programmers

Optimizing Data Accessin Sq Lserver2005
Optimizing Data Accessin Sq Lserver2005Optimizing Data Accessin Sq Lserver2005
Optimizing Data Accessin Sq Lserver2005rainynovember12
 
05_DP_300T00A_Optimize.pptx
05_DP_300T00A_Optimize.pptx05_DP_300T00A_Optimize.pptx
05_DP_300T00A_Optimize.pptxKareemBullard1
 
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
 
Presentación Oracle Database Migración consideraciones 10g/11g/12c
Presentación Oracle Database Migración consideraciones 10g/11g/12cPresentación Oracle Database Migración consideraciones 10g/11g/12c
Presentación Oracle Database Migración consideraciones 10g/11g/12cRonald Francisco Vargas Quesada
 
Ssis Best Practices Israel Bi U Ser Group Itay Braun
Ssis Best Practices   Israel Bi U Ser Group   Itay BraunSsis Best Practices   Israel Bi U Ser Group   Itay Braun
Ssis Best Practices Israel Bi U Ser Group Itay Braunsqlserver.co.il
 
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
 
Overview of query evaluation
Overview of query evaluationOverview of query evaluation
Overview of query evaluationavniS
 
Sql tuning guideline
Sql tuning guidelineSql tuning guideline
Sql tuning guidelineSidney Chen
 
Oracle Sql Tuning
Oracle Sql TuningOracle Sql Tuning
Oracle Sql TuningChris Adkin
 
Myth busters - performance tuning 102 2008
Myth busters - performance tuning 102 2008Myth busters - performance tuning 102 2008
Myth busters - performance tuning 102 2008paulguerin
 
AWS July Webinar Series: Amazon redshift migration and load data 20150722
AWS July Webinar Series: Amazon redshift migration and load data 20150722AWS July Webinar Series: Amazon redshift migration and load data 20150722
AWS July Webinar Series: Amazon redshift migration and load data 20150722Amazon Web Services
 
Sql Server Performance Tuning
Sql Server Performance TuningSql Server Performance Tuning
Sql Server Performance TuningBala Subra
 
Advance Sql Server Store procedure Presentation
Advance Sql Server Store procedure PresentationAdvance Sql Server Store procedure Presentation
Advance Sql Server Store procedure PresentationAmin Uddin
 
Beginners guide to_optimizer
Beginners guide to_optimizerBeginners guide to_optimizer
Beginners guide to_optimizerMaria Colgan
 
Sql server performance tuning
Sql server performance tuningSql server performance tuning
Sql server performance tuningJugal Shah
 
R12 d49656 gc10-apps dba 07
R12 d49656 gc10-apps dba 07R12 d49656 gc10-apps dba 07
R12 d49656 gc10-apps dba 07zeesniper
 
Loading Data into Redshift: Data Analytics Week at the SF Loft
Loading Data into Redshift: Data Analytics Week at the SF LoftLoading Data into Redshift: Data Analytics Week at the SF Loft
Loading Data into Redshift: Data Analytics Week at the SF LoftAmazon Web Services
 
Dynamics ax performance tuning
Dynamics ax performance tuningDynamics ax performance tuning
Dynamics ax performance tuningOutsourceAX
 

Semelhante a SQL Server 2008 Development for Programmers (20)

Optimizing Data Accessin Sq Lserver2005
Optimizing Data Accessin Sq Lserver2005Optimizing Data Accessin Sq Lserver2005
Optimizing Data Accessin Sq Lserver2005
 
05_DP_300T00A_Optimize.pptx
05_DP_300T00A_Optimize.pptx05_DP_300T00A_Optimize.pptx
05_DP_300T00A_Optimize.pptx
 
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
 
Presentación Oracle Database Migración consideraciones 10g/11g/12c
Presentación Oracle Database Migración consideraciones 10g/11g/12cPresentación Oracle Database Migración consideraciones 10g/11g/12c
Presentación Oracle Database Migración consideraciones 10g/11g/12c
 
Ssis Best Practices Israel Bi U Ser Group Itay Braun
Ssis Best Practices   Israel Bi U Ser Group   Itay BraunSsis Best Practices   Israel Bi U Ser Group   Itay Braun
Ssis Best Practices Israel Bi U Ser Group Itay Braun
 
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
 
Overview of query evaluation
Overview of query evaluationOverview of query evaluation
Overview of query evaluation
 
Sql Server
Sql ServerSql Server
Sql Server
 
ETL
ETL ETL
ETL
 
Sql tuning guideline
Sql tuning guidelineSql tuning guideline
Sql tuning guideline
 
Oracle Sql Tuning
Oracle Sql TuningOracle Sql Tuning
Oracle Sql Tuning
 
Myth busters - performance tuning 102 2008
Myth busters - performance tuning 102 2008Myth busters - performance tuning 102 2008
Myth busters - performance tuning 102 2008
 
AWS July Webinar Series: Amazon redshift migration and load data 20150722
AWS July Webinar Series: Amazon redshift migration and load data 20150722AWS July Webinar Series: Amazon redshift migration and load data 20150722
AWS July Webinar Series: Amazon redshift migration and load data 20150722
 
Sql Server Performance Tuning
Sql Server Performance TuningSql Server Performance Tuning
Sql Server Performance Tuning
 
Advance Sql Server Store procedure Presentation
Advance Sql Server Store procedure PresentationAdvance Sql Server Store procedure Presentation
Advance Sql Server Store procedure Presentation
 
Beginners guide to_optimizer
Beginners guide to_optimizerBeginners guide to_optimizer
Beginners guide to_optimizer
 
Sql server performance tuning
Sql server performance tuningSql server performance tuning
Sql server performance tuning
 
R12 d49656 gc10-apps dba 07
R12 d49656 gc10-apps dba 07R12 d49656 gc10-apps dba 07
R12 d49656 gc10-apps dba 07
 
Loading Data into Redshift: Data Analytics Week at the SF Loft
Loading Data into Redshift: Data Analytics Week at the SF LoftLoading Data into Redshift: Data Analytics Week at the SF Loft
Loading Data into Redshift: Data Analytics Week at the SF Loft
 
Dynamics ax performance tuning
Dynamics ax performance tuningDynamics ax performance tuning
Dynamics ax performance tuning
 

Último

IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
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
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
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
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 

Último (20)

IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 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
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
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...
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 

SQL Server 2008 Development for Programmers

  • 1. SQL Server 2008 Development for Programmers(Level 200) Springfield .NET Users Group June 28th, 2011 Presentation by Adam Hutson
  • 2. Speaker Bio – Adam Hutson Database Developer at Expedia and a freelance developer.   11 year career, mostly on software side, on database side for past couple years.   Enjoy learning new development techniques, earning MSSQL certifications, and picking up various web & desktop development side projects. Married 8 yrs & 4 kiddos (B-6y, G-4y, G-2y, & G-5m) Blog: http://adamhutson.com/LinkedIn: http://www.linkedin.com/in/adamhutson
  • 3. Presentation Overview Review of CRUD & JOIN basics Dynamic vs. Compiled Statements Indexes & Execution Plans Performance Issues Scaling up your Database Personal toolbox, templates, & links
  • 4. CRUD basics Create  INSERT statementsINSERTMyTable(Col1, Col2)VALUES ('a','b') Read  SELECT statementsSELECT Col1, Col2 FROMMyTable Update  UPDATE statementsUPDATE MyTable SET Col1 = Col1 + Col1 Delete  DELETE statementsDELETEFROMMyTableWHERE Col2 ='b'
  • 5. JOIN basics [INNER] JOIN LEFT [OUTER] JOIN RIGHT [OUTER] JOIN FULL [OUTER] JOIN CROSS JOIN
  • 6. [INNER] JOIN INNER Joins combine the matching records from 2 tables. INNER keyword is optional.
  • 7. LEFT [OUTER] JOIN LEFT [OUTER] JOINs combine all the records from the left table and only the matching records from right table. OUTER keyword is optional.
  • 8. RIGHT [OUTER] JOIN RIGHT [OUTER] JOINs combine all the records from the right table and only the matching records from left table. OUTER keyword is optional.
  • 9. FULL [OUTER] JOIN FULL [OUTER] JOINs combine all rows from both tables regardless of match. OUTER keyword is optional.
  • 10. CROSS JOIN CROSS JOINs provide a Cartesian product between two tables. A Cartesian product contains all the rows from all the tables combined.
  • 11. Dynamic vs. Compiled Statements Dynamic SQL Statements Constructed at runtime with variable data Execution plan is determined on 1stexecution Any adhoc query is dynamic to the optimizer Compiled SQL Statements Constructed at design time Execution plan is known before execution Stored Procedures are compiled
  • 12. Execution Plans What is an execution plan? Query optimizer’s attempt to calculate the most efficient way to implement a query. Calculates the cost in terms of CPU, I/O, & speed. Where are they stored? Generating an execution plan is expensive, so they are stored for reuse in memory (plan cache). Are purged from memory using an aging formula that considers it’s cost and use
  • 13. Indexes What are indexes? Catalog of locations and order of records in table Why use them? Speeds up queries; tables are just heaps of data without them Types: Clustered NonClustered Composite Unique Covering
  • 14. Index storage An index is a set of pages (index nodes) that are organized in a B-tree structure. Root Level IntermediateLevels Leaf Level
  • 15. Clustered – stores the actual data rows at the leaf level of the index; physically sorted table; only 1 per table NonClustered – leaf nodes contain only the values from the indexed columns and row locators to the actual data rows, not the actual data rows themselves; 249 per table Composite – contains more than one column up to 16; can be clustered or nonclustered; max of 900 bytes Unique – ensures each value in the indexed column is unique. If composite, then the uniqueness is enforced across the columns as a whole. Defining a PK or unique constraint automatically creates a Unique index Covering – includes all the columns that are needed to process a query; an extension of nonclustered functionality; adds non-key columns to the leaf level; not included when calculating number of index key columns or index key size.
  • 16. If a table’s data changes frequently, keep indexes few, simple, & narrow. For tables with a lot of data and infrequent changes, use as many indexes as needed for performance. Create nonclustered indexes on columns used frequently in predicates and join conditions. Index columns with exact match queries. Don’t index small tables, a Table scan is quicker Try to keep predicate order the same as index order Periodically check DMVs for usage and for unused or missing indexes (sys.dm_db_index_usage_stats & sys.dm_db_missing_index_*)
  • 17. Performance Issues Possible causes Blocking CPU Bottlenecks Memory Bottlenecks I/O Bottlenecks Tools to Identify Performance Monitor (PerfMon) SQL Server Profiler DBCC commands DMVs
  • 18. Blocking Blocking is primarily waits for logical locks, which occur when a request to acquire a non-compatible lock on an already-locked resource is made. Identifying: DMVs: sys.dm_os_wait*, sys.dm_tran_locks Profiler: Deadlock graph & Blocked process report
  • 19. CPU Bottlenecks Can be caused by insufficient hardware, poor query tuning, or excessive query compilation. Identifying: PerfMon – “%Processor Time” > 80%, ratio of “SQL Recompilations / sec” to “Batch Requests / sec” be low Profiler – watch SP:Recompile & SQL:StmtRecompile classes DMVs – sys.dm_exec_query_stats & sys.dm_exec_query_optimizer_info
  • 20. Memory Bottlenecks Low memory conditions, or memory pressure Use of AWE & VAS, actual physical memory, other applications Identifying: Task Manager Performance Monitor – “Memory: Available”, “Process: Working Set”, “Paging File:*” DMVs – sys.dm_os_memory_* DBCC MEMORYSTATUS
  • 21. I/O Bottlenecks Check memory first as it can cause I/O Check execution plans for high I/O Identifying: PerfMon – Avg Disk Queue, Avg Disk Sec/Read, Avg Disk Sec/Write, %Disk Time, Avg Disc Reads/Sec, Avg Disk Writes/Sec DMVs – sys.dm_io_* & sys.dm_os_wait_stats where wait_type like 'PAGEIOLATCH%'
  • 22. Scaling it all up Single database design isn’t appropriate here Designs have to incorporate multiple databases over multiple servers with different characteristics Transactional & Analytical needs are different Indexing strategies are different Execution plans should be scrutinized Partitioning becomes pertinent as current and archive data coexist
  • 23. Personal toolbox, templates, & links Watch my website and blog, I’ll post my toolbox of scripts, templates I use for object maintenance, and all the links I keep handy for referencing SQL topics. http://adamhutson.com