SlideShare a Scribd company logo
Chris Adkin
   15 years of IT experience
   14 years of DBA experience
    across a variety of vertical
    sectors.
   Over 10 years experience of SQL
    Server from 2000.
   Contact
    ◦ Email: chris1adkin@yahoo.co.uk
    ◦ Twitter: ChrisAdkin8
 The following material contains
  general rules of thumb.
 Always test your assumptions.
 There will always be edge cases in
  which conventional wisdom may
  not apply.
Characteristic        OLTP                     OLAP
I/O                   Random                   Serial
Transactions          Short                    Longer during ETL
Execution plans       Simple                   Complex
Plan nature           Serial with index seeks Parallel with
                                              index/table /partition
                                              scans
SQL Complexity        Simpler                  Complex, often
                                               generated by BI tools

Number of queries     Finite                   Highly variable
(re)compiles impact   Critical                 Execution plan run
on performance                                 time more important
SQL Selectivity       Queries typically only   Queries aggregate
                      affect a few rows        many rows and affect
                                               many rows during ETL
 Where  the foundation for
  scalability is laid.
 Consider your most
  performance critical queries
  and the number of joins
  they require.
 Data  model design “Usual suspects”:
 ◦ Over normalisation.
 ◦ 1:1 relationships, where most / all
   the attributes from both entities are
   retrieved together.
 ◦ Logical data model sprawl, as the
   model evolves over time.
 1:1   relationships edge cases:
 ◦ Sparse columns, which cannot be
   compressed or used in clustered
   indexes.
 ◦ Infrequently accessed columns with
   wide data types.
 “Walking with keys”
 We only want columns from tables A
  and E and have to go via B, C and D in
  order to facilitate the join.
 The exception is when entities are
  introduced to resolve many to many
  relationships.

    A    B        C        D        E
 Test drive your logical model
  design as early as possible in the
  project.
 Failure to do so may result in
  performance issues built into the
  foundations of the application.
 “Chattiness” => heavy network
  conversation volume between
  software components.
 Chatter takes place via linked
  servers and /or between tiers.
 More time is spent on the network
  than anywhere else.
 Low   IIS and SQL Server CPU
  utilisation is a symptom.
 Cache static / relatively static data
  outside the database.
 Put CRUD intensive operations in
  stored procedures.
 Always put the processing closest
 to the resource that requires it.
 There   is a wider debate about where
  it is best to put the business logic.
 This is beyond the scope of this
  presentation, however you may wish
  to look at:
 ◦ To sp Or Not sp by Adam Machanic
 ◦ Pet vsPet: MS opens .Net benchmarking
   wars
 Start with a minimal set of indexes and
  then add.
 Use filtered indexes for selective SQL.
 Indexing GUIDs:
  ◦ Causes page splits and fragmentation
  ◦ GUIDS are large, 16 bytes
  ◦ Inflates the size of secondary indexes
    created on clustered indexes.
 „Scatter gun‟ indexing strategies can lead
  to indexes that add little or no value.
 Glenn Berry‟s diagnostics script includes a
  query to highlight indexes with lots of
  writes and little or no reads.
 For GUIDs and clustered indexes, refer
  to “The Clustered Index Debate”
  by SQL Skills.
 If you really need GUIDs, consider:
  ◦ NEWSEQUENTIALID().
  ◦ SSD technology as blogged about by
    Tony Rogerson.
 Otherwise avoid GUIDs in general.
   Know your critical indexes and when to rebuild
    and re-organise them.
   The maintenance plan index rebuild tasks
    rebuilds ALL indexes.
   Use index fragmentation and index read
    intensity to determine rebuild / reorg order.
   Some good free tools are available, the
    procedures from Ola Hallengren to name one.
 A compile takes place when a plan
  cannot be found for a statement in the
  plan cache.
 Recompiles take place when the
  execution engine deems that a plan is
  no longer valid.
 All are to be avoided where possible.
Factor            Causes A Compile   Causes A Recompile
Use Of temp tables                                         √
Changes in statistics                                      √
DBCC FREEPROCCACHE / instance          √
restart
Schema changes                                             √
Use of the RECOMPILE hint                                  √
Non parameterised SQL                  √
Dynamic SQL                            √
Plans aged out the plan cache          √
Changes in SET options                                     √
(Refer to Erland Sommarskog‟s
blog)
   There are two hints that help to minimise
    recompiles.
   The KEEP PLAN hint causes the execution engine
    to treat temporary tables as permanent tables.
   The KEEPFIXED PLAN hint will prevent recompiles
    if there are changes to the statistics of base
    tables used in a query.
   Forced parameterisation can minimise
    compiles, but use it with caution.
 There   are many causes of RBAR.
 Cursors.
 User defined functions, table level
  functions are the exception.
 EXISTS sub queries.
 Recursive CTEs.
 . . . and many more, search on SQL
  Server Central for RBAR
 Avoid   RBAR wherever possible.
 Row by agonising row, as coined by
 Jeff Moden, is covered extensively in
 his articles on SQL Server Central.
 Segregate different types of querying
  activity.
 I/O best practise is to segregate
  random from sequential I/O.
   Segregate OLAP/reporting queries
    from OLTP queries.
 ETL aside, OLTP applications are more
  write intensive than OLAP ones.
 Optimisations for reads can decimate
  write performance:
    ◦ Heavy indexing
    ◦ Covering indexes
    ◦ Index views
    ◦ Column store indexes
    ◦ Aggregation
 The Command Query Responsibility
  Segregation model provides a solution.
 Queries insert data into a database
  optimised for fast writes.
 The same data is queued (service broker).
 The data is de-queued and written to a
  database optimised for fast reads.
 An online retailer services thousands of
  concurrent customers.
 A single table holds the balance for the
  retailer in a single row.
 If all transactions can update the balance
  table at the same time, this creates a
  unique point of serialisation.
 Queue the debits credits from the
  user transactions, two options.
 Table with a clustered index, as per
  Remus Rasanu‟s blog and DELETE
  OUTPUT destructive read.
 Service broker is the 2nd option.
 De-queue values and update the
  table.
 Prior to SQL Server 2005, unless dirty
  reads are used, readers block writers.
 This throttles back OTLP through put.
 The solution; multi-version
  concurrency control.
 Facilitated by two new isolation levels
  available in SQL Server 2005 onwards.
 Read   committed snapshot
 ◦ Data is consistent with beginning of
   the statement.
 ◦ An extension of the read committed
   isolation level.
 Snapshot   isolation
 ◦ Data is consistent with the beginning
   of transaction.
 Snapshot / RCSI isolation cannot be
  enabled for databases with filestream
  file groups.
 Queries may have to traverse the
  row version store => more logical and
  physical reads.
 This Microsoft paper provides guidance
  as to which isolation level to use.
 14 bytes of information is added to each
  row in the database as it is modified or
  created.
 Snapshot isolation can lead to update
  conflicts, retry logic is required to work
  around this.
 Ensure tempdb resides on fast disks, as
  this is where the version store lives.
 Latches  protect the integrity of
  internal SQL Server memory
  structures.
 Three latch wait types:
 ◦ Buffer (BUF) : PAGELATCH_* wait type
 ◦ Non buffer : LATCH_* wait type
 ◦ IO latch     : PAGEIOLATCH wait type
 When  multiple threads try to obtain
  the same latch in incompatible
  modes, contention takes place.
 Some latch contention is to be
  expected.
 Refer to this SQLCAT paper for
  detailed information on latch trouble
  shooting.
 If problems exist, long PAGELATCH_*
  and PAGEIOLATCH waits will be
  visible.
 Common causes of latch contention
  include:
  ◦ Heavy CRUD activity affecting rows
    in the same page.
  ◦ Solution is to pad rows out with
    char[X] columns.
 An  index has a leading column
  populated by an identity, sequence
  etc.
 Solution: hash partition the table on
  the indexes leading column.
   Diagnosing and Resolving Latching Issues
    by SQL Customer Advisory Team
   Designing High Scale OLTP Systems
    by Thomas Kejser
   Lessons Learned From 128 Core OLTP Testing
    by Thomas Kejser
Building scalable application with sql server
   Twitter : ChrisAdkin8
   Email   : chris1adkin@yahoo.co.uk

More Related Content

What's hot (20)

PPTX
Super scaling singleton inserts
Chris Adkin
 
PPTX
Low Level CPU Performance Profiling Examples
Tanel Poder
 
PDF
Troubleshooting Complex Performance issues - Oracle SEG$ contention
Tanel Poder
 
PDF
Oracle in-Memory Column Store for BI
Franck Pachot
 
PDF
Tanel Poder - Performance stories from Exadata Migrations
Tanel Poder
 
PDF
Testing Delphix: easy data virtualization
Franck Pachot
 
PDF
Troubleshooting Complex Oracle Performance Problems with Tanel Poder
Tanel Poder
 
PDF
In Memory Database In Action by Tanel Poder and Kerry Osborne
Enkitec
 
PDF
Really Big Elephants: PostgreSQL DW
PostgreSQL Experts, Inc.
 
PDF
PostgreSQL 9.6 Performance-Scalability Improvements
PGConf APAC
 
PDF
Exadata X3 in action: Measuring Smart Scan efficiency with AWR
Franck Pachot
 
PPTX
Christo kutrovsky oracle, memory & linux
Kyle Hailey
 
PDF
Dbvisit replicate: logical replication made easy
Franck Pachot
 
PDF
Webinar slides: The Holy Grail Webinar: Become a MySQL DBA - Database Perform...
Severalnines
 
PDF
PostgreSQL and RAM usage
Alexey Bashtanov
 
PDF
PostgreSQL WAL for DBAs
PGConf APAC
 
PDF
PGConf.ASIA 2019 Bali - Tune Your LInux Box, Not Just PostgreSQL - Ibrar Ahmed
Equnix Business Solutions
 
PDF
Ceph Day Beijing - Optimizing Ceph Performance by Leveraging Intel Optane and...
Danielle Womboldt
 
PDF
PGConf.ASIA 2019 Bali - Building PostgreSQL as a Service with Kubernetes - Ta...
Equnix Business Solutions
 
PDF
Tanel Poder - Troubleshooting Complex Oracle Performance Issues - Part 2
Tanel Poder
 
Super scaling singleton inserts
Chris Adkin
 
Low Level CPU Performance Profiling Examples
Tanel Poder
 
Troubleshooting Complex Performance issues - Oracle SEG$ contention
Tanel Poder
 
Oracle in-Memory Column Store for BI
Franck Pachot
 
Tanel Poder - Performance stories from Exadata Migrations
Tanel Poder
 
Testing Delphix: easy data virtualization
Franck Pachot
 
Troubleshooting Complex Oracle Performance Problems with Tanel Poder
Tanel Poder
 
In Memory Database In Action by Tanel Poder and Kerry Osborne
Enkitec
 
Really Big Elephants: PostgreSQL DW
PostgreSQL Experts, Inc.
 
PostgreSQL 9.6 Performance-Scalability Improvements
PGConf APAC
 
Exadata X3 in action: Measuring Smart Scan efficiency with AWR
Franck Pachot
 
Christo kutrovsky oracle, memory & linux
Kyle Hailey
 
Dbvisit replicate: logical replication made easy
Franck Pachot
 
Webinar slides: The Holy Grail Webinar: Become a MySQL DBA - Database Perform...
Severalnines
 
PostgreSQL and RAM usage
Alexey Bashtanov
 
PostgreSQL WAL for DBAs
PGConf APAC
 
PGConf.ASIA 2019 Bali - Tune Your LInux Box, Not Just PostgreSQL - Ibrar Ahmed
Equnix Business Solutions
 
Ceph Day Beijing - Optimizing Ceph Performance by Leveraging Intel Optane and...
Danielle Womboldt
 
PGConf.ASIA 2019 Bali - Building PostgreSQL as a Service with Kubernetes - Ta...
Equnix Business Solutions
 
Tanel Poder - Troubleshooting Complex Oracle Performance Issues - Part 2
Tanel Poder
 

Similar to Building scalable application with sql server (20)

PPTX
SQL Server 2012 Best Practices
Microsoft TechNet - Belgium and Luxembourg
 
PPTX
Sql good practices
Deepak Mehtani
 
PDF
Backpack Tools4 Sql Dev
Gonçalo Chaves
 
PPTX
SQL Server 2008 Development for Programmers
Adam Hutson
 
PPTX
Database Performance Tuning
Arno Huetter
 
PPTX
Optimizing Application Performance - 2022.pptx
JasonTuran2
 
PPTX
Query Optimization in SQL Server
Rajesh Gunasundaram
 
PDF
Query Tuning for Database Pros & Developers
Code Mastery
 
PDF
SQL Joins and Query Optimization
Brian Gallagher
 
PDF
Speed up sql
Kaing Menglieng
 
PPTX
Sql server infernals
Gianluca Sartori
 
PPT
Performance Tuning And Optimization Microsoft SQL Database
Tung Nguyen Thanh
 
PDF
Sql Performance Tuning For Developers
sqlserver.co.il
 
PPTX
Performance By Design
Guy Harrison
 
PPTX
My Query is slow, now what?
Gianluca Sartori
 
PPT
Ms sql server architecture
Ajeet Singh
 
PPTX
Things you can find in the plan cache
sqlserver.co.il
 
PDF
Breaking data
Terry Bunio
 
PPT
Myth busters - performance tuning 102 2008
paulguerin
 
PDF
Tips for Database Performance
Kesavan Munuswamy
 
SQL Server 2012 Best Practices
Microsoft TechNet - Belgium and Luxembourg
 
Sql good practices
Deepak Mehtani
 
Backpack Tools4 Sql Dev
Gonçalo Chaves
 
SQL Server 2008 Development for Programmers
Adam Hutson
 
Database Performance Tuning
Arno Huetter
 
Optimizing Application Performance - 2022.pptx
JasonTuran2
 
Query Optimization in SQL Server
Rajesh Gunasundaram
 
Query Tuning for Database Pros & Developers
Code Mastery
 
SQL Joins and Query Optimization
Brian Gallagher
 
Speed up sql
Kaing Menglieng
 
Sql server infernals
Gianluca Sartori
 
Performance Tuning And Optimization Microsoft SQL Database
Tung Nguyen Thanh
 
Sql Performance Tuning For Developers
sqlserver.co.il
 
Performance By Design
Guy Harrison
 
My Query is slow, now what?
Gianluca Sartori
 
Ms sql server architecture
Ajeet Singh
 
Things you can find in the plan cache
sqlserver.co.il
 
Breaking data
Terry Bunio
 
Myth busters - performance tuning 102 2008
paulguerin
 
Tips for Database Performance
Kesavan Munuswamy
 
Ad

More from Chris Adkin (9)

PDF
Bdc from bare metal to k8s
Chris Adkin
 
PPTX
Data weekender deploying prod grade sql 2019 big data clusters
Chris Adkin
 
PPTX
Data relay introduction to big data clusters
Chris Adkin
 
PPTX
Ci with jenkins docker and mssql belgium
Chris Adkin
 
PPTX
Continuous Integration With Jenkins Docker SQL Server
Chris Adkin
 
PDF
TSQL Coding Guidelines
Chris Adkin
 
PPT
J2EE Performance And Scalability Bp
Chris Adkin
 
PPT
J2EE Batch Processing
Chris Adkin
 
PPT
Oracle Sql Tuning
Chris Adkin
 
Bdc from bare metal to k8s
Chris Adkin
 
Data weekender deploying prod grade sql 2019 big data clusters
Chris Adkin
 
Data relay introduction to big data clusters
Chris Adkin
 
Ci with jenkins docker and mssql belgium
Chris Adkin
 
Continuous Integration With Jenkins Docker SQL Server
Chris Adkin
 
TSQL Coding Guidelines
Chris Adkin
 
J2EE Performance And Scalability Bp
Chris Adkin
 
J2EE Batch Processing
Chris Adkin
 
Oracle Sql Tuning
Chris Adkin
 
Ad

Recently uploaded (20)

PDF
LLM Search Readiness Audit - Dentsu x SEO Square - June 2025.pdf
Nick Samuel
 
PPTX
Simplifica la seguridad en la nube y la detección de amenazas con FortiCNAPP
Cristian Garcia G.
 
PPTX
MARTSIA: A Tool for Confidential Data Exchange via Public Blockchain - Pitch ...
Michele Kryston
 
PDF
Kubernetes - Architecture & Components.pdf
geethak285
 
PDF
Database Benchmarking for Performance Masterclass: Session 2 - Data Modeling ...
ScyllaDB
 
PDF
UiPath Agentic AI ile Akıllı Otomasyonun Yeni Çağı
UiPathCommunity
 
PPTX
01_Approach Cyber- DORA Incident Management.pptx
FinTech Belgium
 
PPTX
Enabling the Digital Artisan – keynote at ICOCI 2025
Alan Dix
 
PDF
Python Conference Singapore - 19 Jun 2025
ninefyi
 
PDF
Automating the Geo-Referencing of Historic Aerial Photography in Flanders
Safe Software
 
PDF
Hello I'm "AI" Your New _________________
Dr. Tathagat Varma
 
PDF
EIS-Webinar-Engineering-Retail-Infrastructure-06-16-2025.pdf
Earley Information Science
 
PDF
Enhancing Environmental Monitoring with Real-Time Data Integration: Leveragin...
Safe Software
 
PDF
Unlocking FME Flow’s Potential: Architecture Design for Modern Enterprises
Safe Software
 
PDF
Redefining Work in the Age of AI - What to expect? How to prepare? Why it mat...
Malinda Kapuruge
 
PDF
Quantum AI Discoveries: Fractal Patterns Consciousness and Cyclical Universes
Saikat Basu
 
PPTX
Curietech AI in action - Accelerate MuleSoft development
shyamraj55
 
PDF
From Chatbot to Destroyer of Endpoints - Can ChatGPT Automate EDR Bypasses (1...
Priyanka Aash
 
PDF
The Growing Value and Application of FME & GenAI
Safe Software
 
PDF
My Journey from CAD to BIM: A True Underdog Story
Safe Software
 
LLM Search Readiness Audit - Dentsu x SEO Square - June 2025.pdf
Nick Samuel
 
Simplifica la seguridad en la nube y la detección de amenazas con FortiCNAPP
Cristian Garcia G.
 
MARTSIA: A Tool for Confidential Data Exchange via Public Blockchain - Pitch ...
Michele Kryston
 
Kubernetes - Architecture & Components.pdf
geethak285
 
Database Benchmarking for Performance Masterclass: Session 2 - Data Modeling ...
ScyllaDB
 
UiPath Agentic AI ile Akıllı Otomasyonun Yeni Çağı
UiPathCommunity
 
01_Approach Cyber- DORA Incident Management.pptx
FinTech Belgium
 
Enabling the Digital Artisan – keynote at ICOCI 2025
Alan Dix
 
Python Conference Singapore - 19 Jun 2025
ninefyi
 
Automating the Geo-Referencing of Historic Aerial Photography in Flanders
Safe Software
 
Hello I'm "AI" Your New _________________
Dr. Tathagat Varma
 
EIS-Webinar-Engineering-Retail-Infrastructure-06-16-2025.pdf
Earley Information Science
 
Enhancing Environmental Monitoring with Real-Time Data Integration: Leveragin...
Safe Software
 
Unlocking FME Flow’s Potential: Architecture Design for Modern Enterprises
Safe Software
 
Redefining Work in the Age of AI - What to expect? How to prepare? Why it mat...
Malinda Kapuruge
 
Quantum AI Discoveries: Fractal Patterns Consciousness and Cyclical Universes
Saikat Basu
 
Curietech AI in action - Accelerate MuleSoft development
shyamraj55
 
From Chatbot to Destroyer of Endpoints - Can ChatGPT Automate EDR Bypasses (1...
Priyanka Aash
 
The Growing Value and Application of FME & GenAI
Safe Software
 
My Journey from CAD to BIM: A True Underdog Story
Safe Software
 

Building scalable application with sql server

  • 2. 15 years of IT experience  14 years of DBA experience across a variety of vertical sectors.  Over 10 years experience of SQL Server from 2000.  Contact ◦ Email: [email protected] ◦ Twitter: ChrisAdkin8
  • 3.  The following material contains general rules of thumb.  Always test your assumptions.  There will always be edge cases in which conventional wisdom may not apply.
  • 4. Characteristic OLTP OLAP I/O Random Serial Transactions Short Longer during ETL Execution plans Simple Complex Plan nature Serial with index seeks Parallel with index/table /partition scans SQL Complexity Simpler Complex, often generated by BI tools Number of queries Finite Highly variable (re)compiles impact Critical Execution plan run on performance time more important SQL Selectivity Queries typically only Queries aggregate affect a few rows many rows and affect many rows during ETL
  • 5.  Where the foundation for scalability is laid.  Consider your most performance critical queries and the number of joins they require.
  • 6.  Data model design “Usual suspects”: ◦ Over normalisation. ◦ 1:1 relationships, where most / all the attributes from both entities are retrieved together. ◦ Logical data model sprawl, as the model evolves over time.
  • 7.  1:1 relationships edge cases: ◦ Sparse columns, which cannot be compressed or used in clustered indexes. ◦ Infrequently accessed columns with wide data types.
  • 8.  “Walking with keys”  We only want columns from tables A and E and have to go via B, C and D in order to facilitate the join.  The exception is when entities are introduced to resolve many to many relationships. A B C D E
  • 9.  Test drive your logical model design as early as possible in the project.  Failure to do so may result in performance issues built into the foundations of the application.
  • 10.  “Chattiness” => heavy network conversation volume between software components.  Chatter takes place via linked servers and /or between tiers.  More time is spent on the network than anywhere else.
  • 11.  Low IIS and SQL Server CPU utilisation is a symptom.  Cache static / relatively static data outside the database.  Put CRUD intensive operations in stored procedures.  Always put the processing closest to the resource that requires it.
  • 12.  There is a wider debate about where it is best to put the business logic.  This is beyond the scope of this presentation, however you may wish to look at: ◦ To sp Or Not sp by Adam Machanic ◦ Pet vsPet: MS opens .Net benchmarking wars
  • 13.  Start with a minimal set of indexes and then add.  Use filtered indexes for selective SQL.  Indexing GUIDs: ◦ Causes page splits and fragmentation ◦ GUIDS are large, 16 bytes ◦ Inflates the size of secondary indexes created on clustered indexes.
  • 14.  „Scatter gun‟ indexing strategies can lead to indexes that add little or no value.  Glenn Berry‟s diagnostics script includes a query to highlight indexes with lots of writes and little or no reads.
  • 15.  For GUIDs and clustered indexes, refer to “The Clustered Index Debate” by SQL Skills.  If you really need GUIDs, consider: ◦ NEWSEQUENTIALID(). ◦ SSD technology as blogged about by Tony Rogerson.  Otherwise avoid GUIDs in general.
  • 16. Know your critical indexes and when to rebuild and re-organise them.  The maintenance plan index rebuild tasks rebuilds ALL indexes.  Use index fragmentation and index read intensity to determine rebuild / reorg order.  Some good free tools are available, the procedures from Ola Hallengren to name one.
  • 17.  A compile takes place when a plan cannot be found for a statement in the plan cache.  Recompiles take place when the execution engine deems that a plan is no longer valid.  All are to be avoided where possible.
  • 18. Factor Causes A Compile Causes A Recompile Use Of temp tables √ Changes in statistics √ DBCC FREEPROCCACHE / instance √ restart Schema changes √ Use of the RECOMPILE hint √ Non parameterised SQL √ Dynamic SQL √ Plans aged out the plan cache √ Changes in SET options √ (Refer to Erland Sommarskog‟s blog)
  • 19. There are two hints that help to minimise recompiles.  The KEEP PLAN hint causes the execution engine to treat temporary tables as permanent tables.  The KEEPFIXED PLAN hint will prevent recompiles if there are changes to the statistics of base tables used in a query.  Forced parameterisation can minimise compiles, but use it with caution.
  • 20.  There are many causes of RBAR.  Cursors.  User defined functions, table level functions are the exception.  EXISTS sub queries.  Recursive CTEs.  . . . and many more, search on SQL Server Central for RBAR
  • 21.  Avoid RBAR wherever possible.  Row by agonising row, as coined by Jeff Moden, is covered extensively in his articles on SQL Server Central.
  • 22.  Segregate different types of querying activity.  I/O best practise is to segregate random from sequential I/O.  Segregate OLAP/reporting queries from OLTP queries.
  • 23.  ETL aside, OLTP applications are more write intensive than OLAP ones.  Optimisations for reads can decimate write performance: ◦ Heavy indexing ◦ Covering indexes ◦ Index views ◦ Column store indexes ◦ Aggregation
  • 24.  The Command Query Responsibility Segregation model provides a solution.  Queries insert data into a database optimised for fast writes.  The same data is queued (service broker).  The data is de-queued and written to a database optimised for fast reads.
  • 25.  An online retailer services thousands of concurrent customers.  A single table holds the balance for the retailer in a single row.  If all transactions can update the balance table at the same time, this creates a unique point of serialisation.
  • 26.  Queue the debits credits from the user transactions, two options.  Table with a clustered index, as per Remus Rasanu‟s blog and DELETE OUTPUT destructive read.  Service broker is the 2nd option.  De-queue values and update the table.
  • 27.  Prior to SQL Server 2005, unless dirty reads are used, readers block writers.  This throttles back OTLP through put.  The solution; multi-version concurrency control.  Facilitated by two new isolation levels available in SQL Server 2005 onwards.
  • 28.  Read committed snapshot ◦ Data is consistent with beginning of the statement. ◦ An extension of the read committed isolation level.  Snapshot isolation ◦ Data is consistent with the beginning of transaction.
  • 29.  Snapshot / RCSI isolation cannot be enabled for databases with filestream file groups.  Queries may have to traverse the row version store => more logical and physical reads.  This Microsoft paper provides guidance as to which isolation level to use.
  • 30.  14 bytes of information is added to each row in the database as it is modified or created.  Snapshot isolation can lead to update conflicts, retry logic is required to work around this.  Ensure tempdb resides on fast disks, as this is where the version store lives.
  • 31.  Latches protect the integrity of internal SQL Server memory structures.  Three latch wait types: ◦ Buffer (BUF) : PAGELATCH_* wait type ◦ Non buffer : LATCH_* wait type ◦ IO latch : PAGEIOLATCH wait type
  • 32.  When multiple threads try to obtain the same latch in incompatible modes, contention takes place.  Some latch contention is to be expected.  Refer to this SQLCAT paper for detailed information on latch trouble shooting.
  • 33.  If problems exist, long PAGELATCH_* and PAGEIOLATCH waits will be visible.  Common causes of latch contention include: ◦ Heavy CRUD activity affecting rows in the same page. ◦ Solution is to pad rows out with char[X] columns.
  • 34.  An index has a leading column populated by an identity, sequence etc.  Solution: hash partition the table on the indexes leading column.
  • 35. Diagnosing and Resolving Latching Issues by SQL Customer Advisory Team  Designing High Scale OLTP Systems by Thomas Kejser  Lessons Learned From 128 Core OLTP Testing by Thomas Kejser
  • 37. Twitter : ChrisAdkin8  Email : [email protected]