SlideShare une entreprise Scribd logo
1  sur  42
Parallelism in SQL Server
Enrique Catala Bañuls
Mentor, SolidQ
ecatala@solidq.com
Twitter: @enriquecatala
Enrique Catala Bañuls

 Computer engineer
 Mentor at SolidQ in the relational engine
  team
 Microsoft Technical Ranger
 Microsoft Active Professional since 2010
 Microsoft Certified Trainer
Our Sponsors:
Volunteers:
 They spend their FREE time to give you this
  event. (2 months per person)
 Because they are crazy.
 Because they want YOU
      to learn from the BEST IN THE WORLD.
 If you see a guy with “STAFF” on their back –
  buy them a beer, they deserve it.
Paulo Matos:
Paulo Borges:
João Fialho:
Bruno Basto:
Objectives of this session

    Basics on parallelism
    Settings to adjust parallelism
    Exchange operators
    Enemies of the parallelism
    Best practices




9 | 3/20/2013 |
Parallelism

 “Parallelism is the action of executing a
  single task across several CPUs”
 It enhances performance taking advance of
  newest HW configurations
Parallelism benefits
 SQL Server uses all CPU by default
 Generally the queries that qualify for parallelism are
  high IO queries
SMP

   Symmetric multiprocessing (SMP) system
   All the CPUs share the same main memory
   No hardware partitioning for memory access
   Typically used in smaller computers

                      SMP architecture
            CPU CPU CPU CPU CPU CPU CPU CPU

                       System bus
                                    CPU       CPU
                           F
              Main
                           S
             Memory     Memory
                           B
                                    CPU       CPU
NUMA

 Non-Uniform Memory Access
 Nodes connected by shared bus, cross-bar,
  ring
 Typically used in high-end computers

   CPU CPU CPU CPU     CPU CPU CPU CPU     CPU CPU CPU CPU     CPU CPU CPU CPU

     Memory              Memory              Memory              Memory
    Controller          Controller          Controller          Controller

     Node Controller     Node Controller     Node Controller     Node Controller


                                     Shared Bus
NUMA

 SQL Server is NUMA aware
   Automatically detects NUMA configuration
 Minimizes the memory latency by using local
  memory in each node
 SQL Server must be properly configured to
  gain the best performance in NUMA systems
SQL Server Execution Model
  SQLOS
               SQLOS creates a scheduler for
Memory Node
                each logical CPU
               A scheduler is like a logical
CPU Node        CPU used by SQL Server
 Scheduler
                workers
               Only one worker can be executed
  Worker        by a scheduler at the same time
               The unit of work for a worker is a
   Task
                task
Schedulers and concurrency

 Pre-emptive scheduler (Windows)
    Windows uses pre-emptive scheduling because of its general
     operating system nature
    It uses a priority-driven architecture
    Each thread executes in a predetermined time slice
    A thread can be preempted by a higher priority thread
 Cooperative scheduler (SQL Server)
    Each task puts itself in the waiting list every time it needs a
     resource
    The same scheduler executes until the end
    This voluntary yielding by workers prevents context switching
     and improves performance
Objectives of this session

     Basics on parallelism
     Settings to adjust parallelism
     Exchange operators
     Enemies of the parallelism
     Best practices




17 | 3/20/2013 |
Settings to adjust parallelism
 Hardware level
    NUMA
 Instance level
      Soft-NUMA (affinity mask)
      Degree of parallelism
      Cost threshold for parallelism
      Max worker threads
      -P parameter
 Connection level
    Resource Governor by configuring MAXDOP
 Query level
    MAXDOP clause
    T-SQL patterns
         CROSS APPLY
         Functions…
CPU Affinity Mask
• Used to set which processor(s) can be used by the SQL
  Server instance.
• Setting a processor affinity will tie the threads to a particular
  processor
Affinity I/O Mask

 Used to affinitize the CPU usage to I/O
  operations
 Each I/O operation needs to be finalized
   Byte checksum, number of transferred bytes,
    page number okay, etc.
   CPU consumption
 Can be used to specify the lazy writer (in a
  new hidden scheduler)
         Bad                Good
Network affinity

                    8000


                   8001



                   8002




                    8003
Threshold for parallelism

 Instance level configuration
 Change statistically the parallel execution
   Changes the boundaries of when a serial plan should be
    changed to parallel plan


 if(best_plan_for_now.cost<1) return(best_plan_for_now)
 else if(MAXDOP>0
        and best_plan.cost > threshold for parallelism)
 return(MIN(create_paralel_plan().cost, best_plan_for_now))
Demonstration 1




  Affinity mask, cost threshold for
             parallelism
Degree of parallelism (DOP)

 Max degree of parallelism
   o Instance setting that affects the whole instance
   o Can be configured at resource governor´s
     workload level
   o Enforces the maximum number of CPUs that a
     single worker can use
 MAXDOP hint
   o Can be used at query level
Demonstration 2




             MAXDOP
Objectives of this session

     Basics on parallelism
     Settings to adjust parallelism
     Exchange operators
     Enemies of the parallelism
     Best practices




26 | 3/20/2013 |
Exchange operators

 Operators dedicated to moving rows between
  one or more workers, distributing individual
  rows among them
Distribute streams operator
 Row distribution based on
    Hash
        Each row computed a hash and each thread Works only with the rows that have
         the same hash
    Round-robin
        Each row is sent to the following thread of a round-robin
    Broadcast
        All rows are sent to all threads
    Range
        Each row is sent to a thread based on a range computation over a column
        Rare and used in some parallel index creation operations
    Demand
        Pull mode
        It SENDS the row to the operator is calling
        It appears on partitioned tables
Repartition streams operator

 Takes rows from multiple sources and send rows
  to multiple destinations
 Doesn´t update any row
Gather streams operator

 It takes rows from multiple sources and send
  to a single destination (thread)
 Tipically increases CXPACKETS
Demonstration 3




           OPERATORS
Objectives of this session

     Basics on parallelism
     Settings to adjust parallelism
     Exchange operators
     Enemies of the parallelism
     Best practices




32 | 3/20/2013 |
Enemies of the parallelism
 Makes the whole plan serial
    Modifying the contents of a table variable (reading is fine)
    Any T-SQL scalar function
    CLR scalar functions marked as performing data access (normal ones
     are fine)
    Random intrinsic functions including OBJECT_NAME,
     ENCYPTBYCERT, and IDENT_CURRENT
    System table access (e.g. sys.tables)
 Serial zones
      TOP
      Sequence project (e.g. ROW_NUMBER, RANK)
      Multi-statement T-SQL table-valued functions
      Backward range scans (forward is fine)
      Global scalar aggregates
      Common sub-expression spools
      Recursive CTEs
Demonstration 4




 ENEMIES OF THE PARALLELISM
CXPACKET
Serial     Parallel   Serial
Demonstration 5




            CXPACKET
Objectives of this session

     Basics on parallelism
     Settings to adjust parallelism
     Exchange operators
     Enemies of the parallelism
     Best practices




37 | 3/20/2013 |
Best practices
 Never trust the default configuration for the
  degree of parallelism
    By default, MAXDOP = 0
 As a general rule
    Pure OLTP should use MAXDOP = 1
    MAXDOP not to exceed the number of physical cores
    If NUMA architecture,
     MAXDOP <= #physical_cores_numa_node

                    wait type name          wait time (ms) requests
                    CXPACKET                       786556034 128110444
                    LATCH_EX                       255701441 155553913
                    ASYNC_NETWORK_IO               129888217 19083082
                    PAGEIOLATCH_SH                  83672746   2813207
                    WRITELOG                        70634742 48398646
                    SOS_SCHEDULER_YIELD             47697175 176871743
Best practices

 When to apply MAXDOP?
   ALTER INDEX operations
   Typically set MAXDOP = #_physical_cores
 When to set max degree of parallelism?
   When you see high CXPACKET waits
   OLTP pure systems should set its value to 1
 When to set cost threshold for parallelism?
   When you want to change the number of parallel
    operations statistically
Objectives of this session

     Basics on parallelism
     Settings to adjust parallelism
     Exchange operators
     Enemies of the parallelism
     Best practices




41 | 3/20/2013 |
Thank you!
Parallelism in SQL Server
Enrique Catala Bañuls
Mentor, SolidQ
ecatala@solidq.com
Twitter: @enriquecatala

Contenu connexe

Tendances

Amazon Aurora Storage Demystified: How It All Works (DAT363) - AWS re:Invent ...
Amazon Aurora Storage Demystified: How It All Works (DAT363) - AWS re:Invent ...Amazon Aurora Storage Demystified: How It All Works (DAT363) - AWS re:Invent ...
Amazon Aurora Storage Demystified: How It All Works (DAT363) - AWS re:Invent ...Amazon Web Services
 
Introduction to Databases
Introduction to DatabasesIntroduction to Databases
Introduction to DatabasesRam Kedem
 
MySQL 5.7 トラブルシューティング 性能解析入門編
MySQL 5.7 トラブルシューティング 性能解析入門編MySQL 5.7 トラブルシューティング 性能解析入門編
MySQL 5.7 トラブルシューティング 性能解析入門編Mikiya Okuno
 
Best Practices for the Most Impactful Oracle Database 18c and 19c Features
Best Practices for the Most Impactful Oracle Database 18c and 19c FeaturesBest Practices for the Most Impactful Oracle Database 18c and 19c Features
Best Practices for the Most Impactful Oracle Database 18c and 19c FeaturesMarkus Michalewicz
 
클라우드로 데이터 센터 확장하기 : 하이브리드 환경을 위한 연결 옵션 및 고려사항::강동환::AWS Summit Seoul 2018
클라우드로 데이터 센터 확장하기 : 하이브리드 환경을 위한 연결 옵션 및 고려사항::강동환::AWS Summit Seoul 2018 클라우드로 데이터 센터 확장하기 : 하이브리드 환경을 위한 연결 옵션 및 고려사항::강동환::AWS Summit Seoul 2018
클라우드로 데이터 센터 확장하기 : 하이브리드 환경을 위한 연결 옵션 및 고려사항::강동환::AWS Summit Seoul 2018 Amazon Web Services Korea
 
IO Resource Management on Exadata
IO Resource Management on ExadataIO Resource Management on Exadata
IO Resource Management on ExadataEnkitec
 
Introduction to Oracle ERP
Introduction to Oracle ERPIntroduction to Oracle ERP
Introduction to Oracle ERPBalaji Parsewar
 
IaC로 AWS인프라 관리하기 - 이진성 (AUSG) :: AWS Community Day Online 2021
IaC로 AWS인프라 관리하기 - 이진성 (AUSG) :: AWS Community Day Online 2021IaC로 AWS인프라 관리하기 - 이진성 (AUSG) :: AWS Community Day Online 2021
IaC로 AWS인프라 관리하기 - 이진성 (AUSG) :: AWS Community Day Online 2021AWSKRUG - AWS한국사용자모임
 
Amazon EC2 제대로 사용하기(김상필) - AWS 웨비나 시리즈 2015
Amazon EC2 제대로 사용하기(김상필) - AWS 웨비나 시리즈 2015Amazon EC2 제대로 사용하기(김상필) - AWS 웨비나 시리즈 2015
Amazon EC2 제대로 사용하기(김상필) - AWS 웨비나 시리즈 2015Amazon Web Services Korea
 
Oracle enteprise pbcs drivers and assumptions
Oracle enteprise pbcs drivers and assumptionsOracle enteprise pbcs drivers and assumptions
Oracle enteprise pbcs drivers and assumptionsAmit Sharma
 
Oracle Performance Tools of the Trade
Oracle Performance Tools of the TradeOracle Performance Tools of the Trade
Oracle Performance Tools of the TradeCarlos Sierra
 
취향기반의 개인화 서비스를 통한 이커머스 혁신 – 소성운 ZIGZAG 데이터사이언티스트, 강상원 마이셀럽스 대표:: AWS Cloud We...
취향기반의 개인화 서비스를 통한 이커머스 혁신 – 소성운 ZIGZAG 데이터사이언티스트, 강상원 마이셀럽스 대표:: AWS Cloud We...취향기반의 개인화 서비스를 통한 이커머스 혁신 – 소성운 ZIGZAG 데이터사이언티스트, 강상원 마이셀럽스 대표:: AWS Cloud We...
취향기반의 개인화 서비스를 통한 이커머스 혁신 – 소성운 ZIGZAG 데이터사이언티스트, 강상원 마이셀럽스 대표:: AWS Cloud We...Amazon Web Services Korea
 
Extened warehouse management EWM
Extened warehouse management EWMExtened warehouse management EWM
Extened warehouse management EWMSethuRaja P
 
OSS ERP iDempiereの共通基本操作
OSS ERP iDempiereの共通基本操作OSS ERP iDempiereの共通基本操作
OSS ERP iDempiereの共通基本操作Hideaki Hagiwara
 
固定化か?最新化か?オプティマイザ統計の運用をもう一度考える。 -JPOUG Tech Talk Night #6-
固定化か?最新化か?オプティマイザ統計の運用をもう一度考える。 -JPOUG Tech Talk Night #6-固定化か?最新化か?オプティマイザ統計の運用をもう一度考える。 -JPOUG Tech Talk Night #6-
固定化か?最新化か?オプティマイザ統計の運用をもう一度考える。 -JPOUG Tech Talk Night #6-歩 柴田
 
Oracle dba training
Oracle  dba    training Oracle  dba    training
Oracle dba training P S Rani
 
05_DP_300T00A_Optimize.pptx
05_DP_300T00A_Optimize.pptx05_DP_300T00A_Optimize.pptx
05_DP_300T00A_Optimize.pptxKareemBullard1
 

Tendances (20)

Amazon Aurora Storage Demystified: How It All Works (DAT363) - AWS re:Invent ...
Amazon Aurora Storage Demystified: How It All Works (DAT363) - AWS re:Invent ...Amazon Aurora Storage Demystified: How It All Works (DAT363) - AWS re:Invent ...
Amazon Aurora Storage Demystified: How It All Works (DAT363) - AWS re:Invent ...
 
Introduction to Databases
Introduction to DatabasesIntroduction to Databases
Introduction to Databases
 
MySQL 5.7 トラブルシューティング 性能解析入門編
MySQL 5.7 トラブルシューティング 性能解析入門編MySQL 5.7 トラブルシューティング 性能解析入門編
MySQL 5.7 トラブルシューティング 性能解析入門編
 
Best Practices for the Most Impactful Oracle Database 18c and 19c Features
Best Practices for the Most Impactful Oracle Database 18c and 19c FeaturesBest Practices for the Most Impactful Oracle Database 18c and 19c Features
Best Practices for the Most Impactful Oracle Database 18c and 19c Features
 
클라우드로 데이터 센터 확장하기 : 하이브리드 환경을 위한 연결 옵션 및 고려사항::강동환::AWS Summit Seoul 2018
클라우드로 데이터 센터 확장하기 : 하이브리드 환경을 위한 연결 옵션 및 고려사항::강동환::AWS Summit Seoul 2018 클라우드로 데이터 센터 확장하기 : 하이브리드 환경을 위한 연결 옵션 및 고려사항::강동환::AWS Summit Seoul 2018
클라우드로 데이터 센터 확장하기 : 하이브리드 환경을 위한 연결 옵션 및 고려사항::강동환::AWS Summit Seoul 2018
 
Netezza pure data
Netezza pure dataNetezza pure data
Netezza pure data
 
IO Resource Management on Exadata
IO Resource Management on ExadataIO Resource Management on Exadata
IO Resource Management on Exadata
 
Introduction to Oracle ERP
Introduction to Oracle ERPIntroduction to Oracle ERP
Introduction to Oracle ERP
 
Exadata Cloud Service Overview(v2)
Exadata Cloud Service Overview(v2) Exadata Cloud Service Overview(v2)
Exadata Cloud Service Overview(v2)
 
IaC로 AWS인프라 관리하기 - 이진성 (AUSG) :: AWS Community Day Online 2021
IaC로 AWS인프라 관리하기 - 이진성 (AUSG) :: AWS Community Day Online 2021IaC로 AWS인프라 관리하기 - 이진성 (AUSG) :: AWS Community Day Online 2021
IaC로 AWS인프라 관리하기 - 이진성 (AUSG) :: AWS Community Day Online 2021
 
Amazon EC2 제대로 사용하기(김상필) - AWS 웨비나 시리즈 2015
Amazon EC2 제대로 사용하기(김상필) - AWS 웨비나 시리즈 2015Amazon EC2 제대로 사용하기(김상필) - AWS 웨비나 시리즈 2015
Amazon EC2 제대로 사용하기(김상필) - AWS 웨비나 시리즈 2015
 
Oracle enteprise pbcs drivers and assumptions
Oracle enteprise pbcs drivers and assumptionsOracle enteprise pbcs drivers and assumptions
Oracle enteprise pbcs drivers and assumptions
 
Oracle Performance Tools of the Trade
Oracle Performance Tools of the TradeOracle Performance Tools of the Trade
Oracle Performance Tools of the Trade
 
Enterprise manager 13c
Enterprise manager 13cEnterprise manager 13c
Enterprise manager 13c
 
취향기반의 개인화 서비스를 통한 이커머스 혁신 – 소성운 ZIGZAG 데이터사이언티스트, 강상원 마이셀럽스 대표:: AWS Cloud We...
취향기반의 개인화 서비스를 통한 이커머스 혁신 – 소성운 ZIGZAG 데이터사이언티스트, 강상원 마이셀럽스 대표:: AWS Cloud We...취향기반의 개인화 서비스를 통한 이커머스 혁신 – 소성운 ZIGZAG 데이터사이언티스트, 강상원 마이셀럽스 대표:: AWS Cloud We...
취향기반의 개인화 서비스를 통한 이커머스 혁신 – 소성운 ZIGZAG 데이터사이언티스트, 강상원 마이셀럽스 대표:: AWS Cloud We...
 
Extened warehouse management EWM
Extened warehouse management EWMExtened warehouse management EWM
Extened warehouse management EWM
 
OSS ERP iDempiereの共通基本操作
OSS ERP iDempiereの共通基本操作OSS ERP iDempiereの共通基本操作
OSS ERP iDempiereの共通基本操作
 
固定化か?最新化か?オプティマイザ統計の運用をもう一度考える。 -JPOUG Tech Talk Night #6-
固定化か?最新化か?オプティマイザ統計の運用をもう一度考える。 -JPOUG Tech Talk Night #6-固定化か?最新化か?オプティマイザ統計の運用をもう一度考える。 -JPOUG Tech Talk Night #6-
固定化か?最新化か?オプティマイザ統計の運用をもう一度考える。 -JPOUG Tech Talk Night #6-
 
Oracle dba training
Oracle  dba    training Oracle  dba    training
Oracle dba training
 
05_DP_300T00A_Optimize.pptx
05_DP_300T00A_Optimize.pptx05_DP_300T00A_Optimize.pptx
05_DP_300T00A_Optimize.pptx
 

Similaire à Parallelism in sql server

CPN302 your-linux-ami-optimization-and-performance
CPN302 your-linux-ami-optimization-and-performanceCPN302 your-linux-ami-optimization-and-performance
CPN302 your-linux-ami-optimization-and-performanceCoburn Watson
 
Concurrent Replication of Parallel and Distributed Simulations
Concurrent Replication of Parallel and Distributed SimulationsConcurrent Replication of Parallel and Distributed Simulations
Concurrent Replication of Parallel and Distributed SimulationsGabriele D'Angelo
 
Your Linux AMI: Optimization and Performance (CPN302) | AWS re:Invent 2013
Your Linux AMI: Optimization and Performance (CPN302) | AWS re:Invent 2013Your Linux AMI: Optimization and Performance (CPN302) | AWS re:Invent 2013
Your Linux AMI: Optimization and Performance (CPN302) | AWS re:Invent 2013Amazon Web Services
 
Migration To Multi Core - Parallel Programming Models
Migration To Multi Core - Parallel Programming ModelsMigration To Multi Core - Parallel Programming Models
Migration To Multi Core - Parallel Programming ModelsZvi Avraham
 
Parallel Processing (Part 2)
Parallel Processing (Part 2)Parallel Processing (Part 2)
Parallel Processing (Part 2)Ajeng Savitri
 
CS9222 ADVANCED OPERATING SYSTEMS
CS9222 ADVANCED OPERATING SYSTEMSCS9222 ADVANCED OPERATING SYSTEMS
CS9222 ADVANCED OPERATING SYSTEMSKathirvel Ayyaswamy
 
Assisting User’s Transition to Titan’s Accelerated Architecture
Assisting User’s Transition to Titan’s Accelerated ArchitectureAssisting User’s Transition to Titan’s Accelerated Architecture
Assisting User’s Transition to Titan’s Accelerated Architectureinside-BigData.com
 
Approximation techniques used for general purpose algorithms
Approximation techniques used for general purpose algorithmsApproximation techniques used for general purpose algorithms
Approximation techniques used for general purpose algorithmsSabidur Rahman
 
Real-Time Analytics with Kafka, Cassandra and Storm
Real-Time Analytics with Kafka, Cassandra and StormReal-Time Analytics with Kafka, Cassandra and Storm
Real-Time Analytics with Kafka, Cassandra and StormJohn Georgiadis
 
Introduction to OpenMP (Performance)
Introduction to OpenMP (Performance)Introduction to OpenMP (Performance)
Introduction to OpenMP (Performance)Akhila Prabhakaran
 
Fast switching of threads between cores - Advanced Operating Systems
Fast switching of threads between cores - Advanced Operating SystemsFast switching of threads between cores - Advanced Operating Systems
Fast switching of threads between cores - Advanced Operating SystemsRuhaim Izmeth
 
Scheduler Activations - Effective Kernel Support for the User-Level Managemen...
Scheduler Activations - Effective Kernel Support for the User-Level Managemen...Scheduler Activations - Effective Kernel Support for the User-Level Managemen...
Scheduler Activations - Effective Kernel Support for the User-Level Managemen...Kasun Gajasinghe
 
Low Latency Execution For Apache Spark
Low Latency Execution For Apache SparkLow Latency Execution For Apache Spark
Low Latency Execution For Apache SparkJen Aman
 

Similaire à Parallelism in sql server (20)

CPN302 your-linux-ami-optimization-and-performance
CPN302 your-linux-ami-optimization-and-performanceCPN302 your-linux-ami-optimization-and-performance
CPN302 your-linux-ami-optimization-and-performance
 
Concurrent Replication of Parallel and Distributed Simulations
Concurrent Replication of Parallel and Distributed SimulationsConcurrent Replication of Parallel and Distributed Simulations
Concurrent Replication of Parallel and Distributed Simulations
 
Your Linux AMI: Optimization and Performance (CPN302) | AWS re:Invent 2013
Your Linux AMI: Optimization and Performance (CPN302) | AWS re:Invent 2013Your Linux AMI: Optimization and Performance (CPN302) | AWS re:Invent 2013
Your Linux AMI: Optimization and Performance (CPN302) | AWS re:Invent 2013
 
Migration To Multi Core - Parallel Programming Models
Migration To Multi Core - Parallel Programming ModelsMigration To Multi Core - Parallel Programming Models
Migration To Multi Core - Parallel Programming Models
 
Parallel Processing (Part 2)
Parallel Processing (Part 2)Parallel Processing (Part 2)
Parallel Processing (Part 2)
 
CS9222 ADVANCED OPERATING SYSTEMS
CS9222 ADVANCED OPERATING SYSTEMSCS9222 ADVANCED OPERATING SYSTEMS
CS9222 ADVANCED OPERATING SYSTEMS
 
Assisting User’s Transition to Titan’s Accelerated Architecture
Assisting User’s Transition to Titan’s Accelerated ArchitectureAssisting User’s Transition to Titan’s Accelerated Architecture
Assisting User’s Transition to Titan’s Accelerated Architecture
 
Balancing Power & Performance Webinar
Balancing Power & Performance WebinarBalancing Power & Performance Webinar
Balancing Power & Performance Webinar
 
Approximation techniques used for general purpose algorithms
Approximation techniques used for general purpose algorithmsApproximation techniques used for general purpose algorithms
Approximation techniques used for general purpose algorithms
 
3rd 3DDRESD: ReCPU 4 NIDS
3rd 3DDRESD: ReCPU 4 NIDS3rd 3DDRESD: ReCPU 4 NIDS
3rd 3DDRESD: ReCPU 4 NIDS
 
Deep Dive on Amazon EC2
Deep Dive on Amazon EC2Deep Dive on Amazon EC2
Deep Dive on Amazon EC2
 
Cc module 3.pptx
Cc module 3.pptxCc module 3.pptx
Cc module 3.pptx
 
Nbvtalkataitamimageprocessingconf
NbvtalkataitamimageprocessingconfNbvtalkataitamimageprocessingconf
Nbvtalkataitamimageprocessingconf
 
Real-Time Analytics with Kafka, Cassandra and Storm
Real-Time Analytics with Kafka, Cassandra and StormReal-Time Analytics with Kafka, Cassandra and Storm
Real-Time Analytics with Kafka, Cassandra and Storm
 
Introduction to OpenMP (Performance)
Introduction to OpenMP (Performance)Introduction to OpenMP (Performance)
Introduction to OpenMP (Performance)
 
Fast switching of threads between cores - Advanced Operating Systems
Fast switching of threads between cores - Advanced Operating SystemsFast switching of threads between cores - Advanced Operating Systems
Fast switching of threads between cores - Advanced Operating Systems
 
Scheduler Activations - Effective Kernel Support for the User-Level Managemen...
Scheduler Activations - Effective Kernel Support for the User-Level Managemen...Scheduler Activations - Effective Kernel Support for the User-Level Managemen...
Scheduler Activations - Effective Kernel Support for the User-Level Managemen...
 
No sql
No sqlNo sql
No sql
 
Low Latency Execution For Apache Spark
Low Latency Execution For Apache SparkLow Latency Execution For Apache Spark
Low Latency Execution For Apache Spark
 
Routing simulator
Routing simulatorRouting simulator
Routing simulator
 

Plus de Enrique Catala Bañuls

Sql server ha muerto, larga vida a sql server
Sql server ha muerto, larga vida a sql serverSql server ha muerto, larga vida a sql server
Sql server ha muerto, larga vida a sql serverEnrique Catala Bañuls
 
Capas de acceso a datos .net escalables de verdad contra SQL Server
Capas de acceso a datos .net escalables de verdad contra SQL ServerCapas de acceso a datos .net escalables de verdad contra SQL Server
Capas de acceso a datos .net escalables de verdad contra SQL ServerEnrique Catala Bañuls
 
Aplicando R al análisis de rendimiento de un servidor
Aplicando R al análisis de rendimiento de un servidorAplicando R al análisis de rendimiento de un servidor
Aplicando R al análisis de rendimiento de un servidorEnrique Catala Bañuls
 
Técnicas avanzadas para resolver tus problemas de sql server
Técnicas avanzadas para resolver tus problemas de sql serverTécnicas avanzadas para resolver tus problemas de sql server
Técnicas avanzadas para resolver tus problemas de sql serverEnrique Catala Bañuls
 
Capas de acceso a datos .NET escalables de verdad: el batido perfecto para el...
Capas de acceso a datos .NET escalables de verdad: el batido perfecto para el...Capas de acceso a datos .NET escalables de verdad: el batido perfecto para el...
Capas de acceso a datos .NET escalables de verdad: el batido perfecto para el...Enrique Catala Bañuls
 
Planes de ejecución 3.0 sql 2016 y v next
Planes de ejecución 3.0 sql 2016 y v nextPlanes de ejecución 3.0 sql 2016 y v next
Planes de ejecución 3.0 sql 2016 y v nextEnrique Catala Bañuls
 
Aplicando R al análisis de rendimiento de un servidor
Aplicando R al análisis de rendimiento de un servidorAplicando R al análisis de rendimiento de un servidor
Aplicando R al análisis de rendimiento de un servidorEnrique Catala Bañuls
 
Sql server 2016 novedades para desarrolladores
Sql server 2016 novedades para desarrolladoresSql server 2016 novedades para desarrolladores
Sql server 2016 novedades para desarrolladoresEnrique Catala Bañuls
 
Dawarehouse como servicio en azure (sqldw)
Dawarehouse como servicio en azure (sqldw)Dawarehouse como servicio en azure (sqldw)
Dawarehouse como servicio en azure (sqldw)Enrique Catala Bañuls
 
Datawarehouse como servicio en azure (sqldw)
Datawarehouse como servicio en azure (sqldw)Datawarehouse como servicio en azure (sqldw)
Datawarehouse como servicio en azure (sqldw)Enrique Catala Bañuls
 
Como hacer tuning a capas de acceso a datos en .NET (dotNetConference2016)
Como hacer tuning a capas de acceso a datos en .NET (dotNetConference2016)Como hacer tuning a capas de acceso a datos en .NET (dotNetConference2016)
Como hacer tuning a capas de acceso a datos en .NET (dotNetConference2016)Enrique Catala Bañuls
 
Como leer planes de ejecución - edición 2015
Como leer planes de ejecución - edición 2015Como leer planes de ejecución - edición 2015
Como leer planes de ejecución - edición 2015Enrique Catala Bañuls
 

Plus de Enrique Catala Bañuls (20)

Sql server ha muerto, larga vida a sql server
Sql server ha muerto, larga vida a sql serverSql server ha muerto, larga vida a sql server
Sql server ha muerto, larga vida a sql server
 
Capas de acceso a datos .net escalables de verdad contra SQL Server
Capas de acceso a datos .net escalables de verdad contra SQL ServerCapas de acceso a datos .net escalables de verdad contra SQL Server
Capas de acceso a datos .net escalables de verdad contra SQL Server
 
Paralelismo en SQL Server
Paralelismo en SQL ServerParalelismo en SQL Server
Paralelismo en SQL Server
 
Aplicando R al análisis de rendimiento de un servidor
Aplicando R al análisis de rendimiento de un servidorAplicando R al análisis de rendimiento de un servidor
Aplicando R al análisis de rendimiento de un servidor
 
Técnicas avanzadas para resolver tus problemas de sql server
Técnicas avanzadas para resolver tus problemas de sql serverTécnicas avanzadas para resolver tus problemas de sql server
Técnicas avanzadas para resolver tus problemas de sql server
 
Capas de acceso a datos .NET escalables de verdad: el batido perfecto para el...
Capas de acceso a datos .NET escalables de verdad: el batido perfecto para el...Capas de acceso a datos .NET escalables de verdad: el batido perfecto para el...
Capas de acceso a datos .NET escalables de verdad: el batido perfecto para el...
 
Planes de ejecución 3.0 sql 2016 y v next
Planes de ejecución 3.0 sql 2016 y v nextPlanes de ejecución 3.0 sql 2016 y v next
Planes de ejecución 3.0 sql 2016 y v next
 
Paralelismo en sql server
Paralelismo en sql serverParalelismo en sql server
Paralelismo en sql server
 
Aplicando R al análisis de rendimiento de un servidor
Aplicando R al análisis de rendimiento de un servidorAplicando R al análisis de rendimiento de un servidor
Aplicando R al análisis de rendimiento de un servidor
 
Query store
Query storeQuery store
Query store
 
Planes de ejecucion 2016
Planes de ejecucion 2016Planes de ejecucion 2016
Planes de ejecucion 2016
 
Sql server 2016 novedades para desarrolladores
Sql server 2016 novedades para desarrolladoresSql server 2016 novedades para desarrolladores
Sql server 2016 novedades para desarrolladores
 
Dawarehouse como servicio en azure (sqldw)
Dawarehouse como servicio en azure (sqldw)Dawarehouse como servicio en azure (sqldw)
Dawarehouse como servicio en azure (sqldw)
 
Query store
Query storeQuery store
Query store
 
Planes de ejecucion 2
Planes de ejecucion 2Planes de ejecucion 2
Planes de ejecucion 2
 
Planes de ejecucion 1
Planes de ejecucion 1Planes de ejecucion 1
Planes de ejecucion 1
 
Migración a sql server 2016
Migración a sql server 2016Migración a sql server 2016
Migración a sql server 2016
 
Datawarehouse como servicio en azure (sqldw)
Datawarehouse como servicio en azure (sqldw)Datawarehouse como servicio en azure (sqldw)
Datawarehouse como servicio en azure (sqldw)
 
Como hacer tuning a capas de acceso a datos en .NET (dotNetConference2016)
Como hacer tuning a capas de acceso a datos en .NET (dotNetConference2016)Como hacer tuning a capas de acceso a datos en .NET (dotNetConference2016)
Como hacer tuning a capas de acceso a datos en .NET (dotNetConference2016)
 
Como leer planes de ejecución - edición 2015
Como leer planes de ejecución - edición 2015Como leer planes de ejecución - edición 2015
Como leer planes de ejecución - edición 2015
 

Dernier

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
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdfChristopherTHyatt
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfhans926745
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
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
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 

Dernier (20)

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
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdf
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
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
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 

Parallelism in sql server

  • 1. Parallelism in SQL Server Enrique Catala Bañuls Mentor, SolidQ ecatala@solidq.com Twitter: @enriquecatala
  • 2. Enrique Catala Bañuls  Computer engineer  Mentor at SolidQ in the relational engine team  Microsoft Technical Ranger  Microsoft Active Professional since 2010  Microsoft Certified Trainer
  • 4. Volunteers:  They spend their FREE time to give you this event. (2 months per person)  Because they are crazy.  Because they want YOU to learn from the BEST IN THE WORLD.  If you see a guy with “STAFF” on their back – buy them a beer, they deserve it.
  • 9. Objectives of this session  Basics on parallelism  Settings to adjust parallelism  Exchange operators  Enemies of the parallelism  Best practices 9 | 3/20/2013 |
  • 10. Parallelism  “Parallelism is the action of executing a single task across several CPUs”  It enhances performance taking advance of newest HW configurations
  • 11. Parallelism benefits  SQL Server uses all CPU by default  Generally the queries that qualify for parallelism are high IO queries
  • 12. SMP  Symmetric multiprocessing (SMP) system  All the CPUs share the same main memory  No hardware partitioning for memory access  Typically used in smaller computers SMP architecture CPU CPU CPU CPU CPU CPU CPU CPU System bus CPU CPU F Main S Memory Memory B CPU CPU
  • 13. NUMA  Non-Uniform Memory Access  Nodes connected by shared bus, cross-bar, ring  Typically used in high-end computers CPU CPU CPU CPU CPU CPU CPU CPU CPU CPU CPU CPU CPU CPU CPU CPU Memory Memory Memory Memory Controller Controller Controller Controller Node Controller Node Controller Node Controller Node Controller Shared Bus
  • 14. NUMA  SQL Server is NUMA aware  Automatically detects NUMA configuration  Minimizes the memory latency by using local memory in each node  SQL Server must be properly configured to gain the best performance in NUMA systems
  • 15. SQL Server Execution Model SQLOS  SQLOS creates a scheduler for Memory Node each logical CPU  A scheduler is like a logical CPU Node CPU used by SQL Server Scheduler workers  Only one worker can be executed Worker by a scheduler at the same time  The unit of work for a worker is a Task task
  • 16. Schedulers and concurrency  Pre-emptive scheduler (Windows)  Windows uses pre-emptive scheduling because of its general operating system nature  It uses a priority-driven architecture  Each thread executes in a predetermined time slice  A thread can be preempted by a higher priority thread  Cooperative scheduler (SQL Server)  Each task puts itself in the waiting list every time it needs a resource  The same scheduler executes until the end  This voluntary yielding by workers prevents context switching and improves performance
  • 17. Objectives of this session  Basics on parallelism  Settings to adjust parallelism  Exchange operators  Enemies of the parallelism  Best practices 17 | 3/20/2013 |
  • 18. Settings to adjust parallelism  Hardware level  NUMA  Instance level  Soft-NUMA (affinity mask)  Degree of parallelism  Cost threshold for parallelism  Max worker threads  -P parameter  Connection level  Resource Governor by configuring MAXDOP  Query level  MAXDOP clause  T-SQL patterns  CROSS APPLY  Functions…
  • 19. CPU Affinity Mask • Used to set which processor(s) can be used by the SQL Server instance. • Setting a processor affinity will tie the threads to a particular processor
  • 20. Affinity I/O Mask  Used to affinitize the CPU usage to I/O operations  Each I/O operation needs to be finalized  Byte checksum, number of transferred bytes, page number okay, etc.  CPU consumption  Can be used to specify the lazy writer (in a new hidden scheduler) Bad Good
  • 21. Network affinity 8000 8001 8002 8003
  • 22. Threshold for parallelism  Instance level configuration  Change statistically the parallel execution  Changes the boundaries of when a serial plan should be changed to parallel plan if(best_plan_for_now.cost<1) return(best_plan_for_now) else if(MAXDOP>0 and best_plan.cost > threshold for parallelism) return(MIN(create_paralel_plan().cost, best_plan_for_now))
  • 23. Demonstration 1 Affinity mask, cost threshold for parallelism
  • 24. Degree of parallelism (DOP)  Max degree of parallelism o Instance setting that affects the whole instance o Can be configured at resource governor´s workload level o Enforces the maximum number of CPUs that a single worker can use  MAXDOP hint o Can be used at query level
  • 25. Demonstration 2 MAXDOP
  • 26. Objectives of this session  Basics on parallelism  Settings to adjust parallelism  Exchange operators  Enemies of the parallelism  Best practices 26 | 3/20/2013 |
  • 27. Exchange operators  Operators dedicated to moving rows between one or more workers, distributing individual rows among them
  • 28. Distribute streams operator  Row distribution based on  Hash  Each row computed a hash and each thread Works only with the rows that have the same hash  Round-robin  Each row is sent to the following thread of a round-robin  Broadcast  All rows are sent to all threads  Range  Each row is sent to a thread based on a range computation over a column  Rare and used in some parallel index creation operations  Demand  Pull mode  It SENDS the row to the operator is calling  It appears on partitioned tables
  • 29. Repartition streams operator  Takes rows from multiple sources and send rows to multiple destinations  Doesn´t update any row
  • 30. Gather streams operator  It takes rows from multiple sources and send to a single destination (thread)  Tipically increases CXPACKETS
  • 31. Demonstration 3 OPERATORS
  • 32. Objectives of this session  Basics on parallelism  Settings to adjust parallelism  Exchange operators  Enemies of the parallelism  Best practices 32 | 3/20/2013 |
  • 33. Enemies of the parallelism  Makes the whole plan serial  Modifying the contents of a table variable (reading is fine)  Any T-SQL scalar function  CLR scalar functions marked as performing data access (normal ones are fine)  Random intrinsic functions including OBJECT_NAME, ENCYPTBYCERT, and IDENT_CURRENT  System table access (e.g. sys.tables)  Serial zones  TOP  Sequence project (e.g. ROW_NUMBER, RANK)  Multi-statement T-SQL table-valued functions  Backward range scans (forward is fine)  Global scalar aggregates  Common sub-expression spools  Recursive CTEs
  • 34. Demonstration 4 ENEMIES OF THE PARALLELISM
  • 35. CXPACKET Serial Parallel Serial
  • 36. Demonstration 5 CXPACKET
  • 37. Objectives of this session  Basics on parallelism  Settings to adjust parallelism  Exchange operators  Enemies of the parallelism  Best practices 37 | 3/20/2013 |
  • 38. Best practices  Never trust the default configuration for the degree of parallelism  By default, MAXDOP = 0  As a general rule  Pure OLTP should use MAXDOP = 1  MAXDOP not to exceed the number of physical cores  If NUMA architecture, MAXDOP <= #physical_cores_numa_node wait type name wait time (ms) requests CXPACKET 786556034 128110444 LATCH_EX 255701441 155553913 ASYNC_NETWORK_IO 129888217 19083082 PAGEIOLATCH_SH 83672746 2813207 WRITELOG 70634742 48398646 SOS_SCHEDULER_YIELD 47697175 176871743
  • 39. Best practices  When to apply MAXDOP?  ALTER INDEX operations  Typically set MAXDOP = #_physical_cores  When to set max degree of parallelism?  When you see high CXPACKET waits  OLTP pure systems should set its value to 1  When to set cost threshold for parallelism?  When you want to change the number of parallel operations statistically
  • 40. Objectives of this session  Basics on parallelism  Settings to adjust parallelism  Exchange operators  Enemies of the parallelism  Best practices 41 | 3/20/2013 |
  • 42. Parallelism in SQL Server Enrique Catala Bañuls Mentor, SolidQ ecatala@solidq.com Twitter: @enriquecatala

Notes de l'éditeur

  1. Thereis a lot of topicsonthis área and i tryedto concéntrate some of themostimportantparts in anhoursession
  2. A quickexample:If i have 200 differentcoins and Iwanttogethowmuchmoney Ihave, i can addonebyone , I can give 100 coinstomypartnertoget a partialresult, orforexample Split mycoinsbetween 10 partnerstoget 10 partialresults and thenobtainhowmuchmoney I have … aftersome “specialfee” youknowThe real time expended gettingtheresultswillnot be thesame and obviouslythemuchpartners i use togetpartialresults, the more quicklyi´llgettheresult….butthisisnotalways true.
  3. Typicalbennefit: the more CPU, the more performance…butitsthat true?It´stipicallon REBUILDING indexes, aggregations, tablescans,…CHART, GRAPHIC
  4. The server iscomposedonmultiple NUMA nodes 2-4 typicallyonthe standard configurationsEach NUMA node has itsown CPU and memoryThe server seesthe sum of CPU and memory and all are accesible from SQL Server
  5. The images show the detection of three-node NUMA hardware by SQL Server and the three lazy writer threads (one per each NUMA node).SQL Server is able to get the best performance in NUMA hardware by doing some special automatic configurations, such as having special threads for some internal components in each NUMA node. Note: Mention that as a common rule, you must configure the MAXDOP value lower than the number of physical cores per each NUMA node. With this configuration, if a query is executed in parallel, all the threads will be in the same node.
  6. the SQLOS is a thin user-mode layer that sits between SQL Server and Windows. It is usedfor low-level operations such as scheduling, I/O completion, memory management, and resourceManagementWhen an execution request is made within a session, SQL Server divides the work into one or moretasks and then associates a worker thread to each task for its duration. Runs in user modeReduces context switchingBetter resource usageMultiprocessing is enhancedA task uses the same scheduler most of the timeMultiple tasks can be executed at the same timeData locality is enforcedBetter scalability on NUMA hardwareSQLOS works the same in each OS host (w2k3, w2k8r2, w2k12, etc.)
  7. why would i do that?
  8. This configuration is mainly for:Systems with more than one SQL Server instanceSystems with more than 32 heavily used CPUs on which you detected specific I/O congestion problemsWhen you don&apos;t use IO affinity the SQL Server worker handles (posts) the IO and takes care of the IO completion on the scheduler the worker was assigned to.The SQL Server GUI on SQL Server 2012 don´tletyoumakemistakesQUESTION: Whyiswrongtheconf “Bad”?REASON: By setting both at the same scheduler they will compete for resources, that is just what you want to avoid.
  9. ENHANCE DATA LOCALITYOnlargesystems, bydoingthiskind of affinity, you can obtain a performance gain of 20%. QUESTION: Why?ANSWER: Becausestatistically, when a scheduler “touches” a datapage, the page isstored at NUMA memory X. if a schedulercommingfromanother NUMA nodeneedstoreadthatspecific page, ittakes 3-4 times the time togetthat page fromoutsideits NUMA node. So bydoingthis, we can forcé specificaplicationstoworkwithspecific NUMA nodes and doingthis, toincreasethepossibilitytoread-write data pagesonthesame NUMA nodes.
  10. 26’
  11. Degree of parallelism (DOP) is assigned at each parallel step of the execution planAll CPUs can be used by the schedulers, so threads can use all available CPUsNo special consideration for hyperthreaded CPUsBy limiting DOP, you can limit the number of available threads to solve a query DOP is determined when execution plan is retrieved from the plan cache
  12. 28
  13. This operator takes a single input stream of records and produces multiple output streams. The record contents and format are not changed. Each record from the input stream appears in one of the output streams. This operator automatically preserves the relative order of the input records in the output streams. Usually, hashing is used to decide to which output stream a particular input record belongs.
  14. operator consumes multiple streams and produces multiple streams of records. The record contents and format are not changed. If the query optimizer uses a bitmap filter, the number of rows in the output stream is reduced. Each record from an input stream is placed into one output stream. If this operator is order preserving, all input streams must be ordered and merged into several ordered output streams. El cálculo si se mira el plan de eejcución en detalle, viene dado por una expresión que se puede obtener ya en el hash match. En el momento del gather se obtiene el valor 6.En la demo 2-exchange_operators.sql se puede ver con detenimiento
  15. consumes several input streams and produces a single output stream of records by combining the input streamsPARALLEL PAGE SUPLIER to divide rowsacrossthreads in batches
  16. 45
  17. There are someenemies of theparalleliam and those are some of them
  18. Paralleloperationsmust be synchronizedbeforeserializyng. So ifsomeworkerendsitsexecution and someotherisstillexecuting, he throws a CXPACKET signalto SQL Server announcingthat he iswaiting and finisheditsexecution. CXPACKET isnot a problemitselfbutitsanindicator of badparallel SQL Server configurationifweseelots of waitsignals of thistype
  19. 50
  20. Here are typical scenarios involving CXPACKET wait statistics.Note: It is very unusual to have a pure OLTP system because most customers uses their SQL Server instances for applications, reports, BI data loading solutions, and more.In the example at the bottom, note that 9 days of CPU time is wasted by CXPACKET (786556034 ms = 13109 minutes = 218 hours = 9 days) in threading synchronization due to a bad configuration. (This is a real example from one of the SolidQ’s customers.)Important: It is very important that the students really understand the degree of parallelism setting. It is very common for students to confuse MAXDOP with CPU AFFINITY. Furthermore, make sure that students understand what is a pure OLTP system.