SlideShare una empresa de Scribd logo
1 de 24
CS5226 Lecture 1
  Introduction
Database Tuning

          ◮    Make a database application run more quickly
                    ◮    higher throughput
                    ◮    lower response time
          ◮    Auto-tuning / self-tuning
                    ◮    Better performance
                    ◮    Easier manageability
          ◮    Query workload
                    ◮    Online transaction processing (OLTP)
                    ◮    Decision support systems (DSS) / Online analytical
                         processing (OLAP) / Data warehousing




CS5226: Sem 2, 2012/13                          Introduction                  2
Anatomy of DBMS




                         (Hellerstein, Stonebraker, Hamilton, 2007)
CS5226: Sem 2, 2012/13                        Introduction            3
Query Optimization

                                                 πX , Y , Z                      project
                                                                                  X,Y,Z
                                                                             sort-merge join
                                               ⊲⊳R .B=T .B
             select R.X, S.Y, T.Z                                               R.B = T.B
             from R, S, T
                                                                       hash join      scan table
             where R.A = S.A            ⊲⊳R .A=S.A              T
                                                                        R.A = S.A       for T
             and R.B = T.B
                                    R                S                         scan index
                                                                scan table
                                                                                on (A,Y)
                                                                  for R
                                                                                  for S
                                    Internal Query                     Physical
                         Query
                                    Representation                    Query Plan




CS5226: Sem 2, 2012/13                           Introduction                                      4
Performance Tuning Knobs

          ◮    Schema tuning
          ◮    Query tuning
          ◮    Index & materialized view selection
          ◮    Statistics tuning
          ◮    Concurrency control tuning
          ◮    Data partitioning
          ◮    Memory tuning
          ◮    Hardware tuning


CS5226: Sem 2, 2012/13                 Introduction   5
Schema Tuning

                                                   CourseInfo
                                 Module    Prof      Room     Building    Time
                                 CS101    Turing      LT 1      CS        0800
                                 CS400    Turing      LT 1      CS        1400
                                 MU300     Bach       LT 2     Math       1400
                                 MA200    Newton      LT 2     Math       1000
                                 CS101    Turing      LT 2     Math       1200


                                                                               Schedule
                                             Course
                                                                       Room       Time    Module
                        Facility           Module    Prof
                                                                        LT 1      0800    CS101
                    Room       Building    CS101    Turing
                                                                        LT 1      1400    CS400
                     LT 1        CS        CS400    Turing
                                                                        LT 2      1400    MU200
                     LT 2        Math      MU300     Bach
                                                                        LT 2      1000    MA200
                                           MA200    Newton
                                                                        LT 2      1200    CS101




CS5226: Sem 2, 2012/13                                  Introduction                               6
Query Tuning
            Q1: select             c.cname
                from               Customer c
                where              1000 < (select sum(o.totalprice)
                                           from Order o
                                           where o.cust# = c.cust#)


            Q2: select            c.cname
                from              Customer c join Order o
                                  on c.cust# = o.cust#
                         group by c.cust#, c.cname
                         having   1000 < sum(o.totalprice)
CS5226: Sem 2, 2012/13                     Introduction               7
Query Tuning (cont.)
       Q3: select          c.cust#, c.cname, sum(o.totalprice) as T
           from            Customer c join Order o
                           on c.cust# = o.cust#
                  group by c.cust#, cname


       Q4: select           c.cust#, cname, T
           from             customer c,
                            (select cust#, sum(totalprice) as T
                            from      Order
                            group by cust#) as o
                  where     c.cust# = o.cust#

CS5226: Sem 2, 2012/13                 Introduction                   8
Query Tuning (cont.)

                         Q5: select distinct R.A, S.X
                             from   R, S
                             where R.B = S.Y


                         Q6: select R.A, S.X
                             from   R, S
                             where R.B = S.Y




CS5226: Sem 2, 2012/13                 Introduction     9
Index Tuning


                            select A, B, C
                            from   R
                            where 10 < A < 20


    Access methods for selection queries:
          ◮    Table scan
          ◮    Use one or more indexes



CS5226: Sem 2, 2012/13               Introduction   10
B+-tree index
                                                                                    18



                                          12               17                                                       22               24


             (Moe,10,55,180)         (Larry,12,70,175)          (Alice,17,48,175)         (John,18,59,182)          (Marcie,22,50,165)         (Sally,24,48,169)
             (Curly,10,65,171)        (Bob,15,60,178)           (Lucy,17,45,170)         (Charlie,20,69,173)         (Linus,23,60,166)         (Tom,25,56,176)


                                                         Clustered index on (age)

                          Relation R
                                                                                                                   59
         name           age      weight        height
          Moe           10         55           180
          Curly          10        65           171
                                                                                          50                                              65
          Larry         12         70           175
           Bob          15         60           178
          Alice         17         48           175
          Lucy          17         45           170                        (45, RID32)               (50, RID51)              (59, RID41)                (65, RID12)
          John          18         59           182                        (48, RID31)               (55, RID11)              (60, RID22)                (69, RID42)
         Charlie        20         69           173                        (48, RID61)               (56, RID62)              (60, RID52)                (70, RID21)
         Marcie         22         50           165
          Linus         23         60           166
          Sally
          Tom
                        24
                        25
                                   48
                                   56
                                                169
                                                176
                                                                          Unclustered index on (weight)


CS5226: Sem 2, 2012/13                                                               Introduction                                                                      11
Index access methods



          ◮    Index scan
          ◮    Index seek [+ RID lookup ]
          ◮    Index intersection [+ RID lookup ]




CS5226: Sem 2, 2012/13                  Introduction   12
Index scan

                                       select    height
                                       from      Student


                                                  (175,48)



                               (170,45)                                   (178,60)



                    (165,50, RID51)       (170,45, RID32)          (175,48, RID31)   (178,60, RID22)
                    (166,60, RID52)       (171,65, RID12)          (175,70, RID21)   (180,55, RID11)
                    (169,48, RID61)       (173,69, RID42)          (176,56, RID62)   (182,59, RID41)



                                      Index on (height,weight)


CS5226: Sem 2, 2012/13                                  Introduction                                   13
Index seek

                             select       weight
                             from         Student
                             where        weight between 55 and 65

                                                59



                                  50                                65



                    (45, RID32)        (50, RID51)   (59, RID41)         (65, RID12)
                    (48, RID31)        (55, RID11)   (60, RID22)         (69, RID42)
                    (48, RID61)        (56, RID62)   (60, RID52)         (70, RID21)



                                        Index on (weight)

CS5226: Sem 2, 2012/13                               Introduction                      14
Index seek + RID lookups
                                                            select             weight
        select       name
                                                            from               Student
        from         Student
                                                            where              weight between 55 and 59
        where        weight between 55 and 59
                                                            and                age ≥ 20

                                                    59



                                  50                                      65        Index on (weight)

                    (45, RID32)           (50, RID51)      (59, RID41)             (65, RID12)
                    (48, RID31)           (55, RID11)      (60, RID22)             (69, RID42)
                    (48, RID61)           (56, RID62)      (60, RID52)             (70, RID21)



          (Moe,10,55,180)              (Larry,12,70,175)     (Alice,17,48,175)
          (Curly,10,65,171)             (Bob,15,60,178)      (Lucy,17,45,170)
                                                                                         Data

         (Sally,24,48,169)         (Marcie,22,50,165)          (John,18,59,182)
         (Tom,25,56,176)            (Linus,23,60,166)         (Charlie,20,69,173)
                                                                                            Pages

CS5226: Sem 2, 2012/13                                     Introduction                                   15
Index intersection

                         select   height, weight from Student
                         where    height between 164 and 170
                         and      weight between 50 and 59

                                                                        (175,48)



                                                 170                                              178

       Index on (height)
                                  (165, RID51)          (170, RID32)          (175, RID31)              (178, RID22)
                                  (166, RID52)          (171, RID12)          (175, RID21)              (180, RID11)
                                  (169, RID61)          (173, RID42)          (176, RID62)              (182, RID41)


                                                                               59



                                                          50                                              65
       Index on (weight)
                                         (45, RID32)           (50, RID51)          (59, RID41)            (65, RID12)
                                         (48, RID31)           (55, RID11)          (60, RID22)            (69, RID42)
                                         (48, RID61)           (56, RID62)          (60, RID52)            (70, RID21)

CS5226: Sem 2, 2012/13                                 Introduction                                                      16
Index Tuning

     Q1:           select   A, B, C
                   from     R
                   where    10 < A < 20
                   and      20 < B < 100

     Q2:           select   B, C, D
                   from     R
                   where    50 < B < 100
                   and      60 < D < 80



CS5226: Sem 2, 2012/13                     Introduction   17
Materialized View Tuning
                         Q1:    select   R.B
                                from     R, S
                                where    R.A = S.X
                                and      S.Y > 100

                         MV1: select R.A, R.B, S.X, S.Y
                              from   R, S
                              where R.A = S.X

                         Q1’:   select B
                                from   MV1
                                where Y > 100
CS5226: Sem 2, 2012/13                    Introduction    18
Tuning of indexes & materialized views



    Given a query workload and a disk space constraint, what
    is the optimal configuration of indexes & materialized views
    to optimize the performance of the workload?




CS5226: Sem 2, 2012/13           Introduction                     19
Tuning of statistics
    Examples of statistics:
          ◮    table cardinality
          ◮    statistics for each column:
                    ◮    number of distinct values
                    ◮    highest & lowest values
                    ◮    frequent values
                    ◮    data distribution statistics
          ◮    multi-column statistics
    Issues
          ◮    What statistics to collect?
          ◮    When to collect/refresh statistics?

CS5226: Sem 2, 2012/13                             Introduction   20
Tuning of concurrency control

          ◮    Concurrency control protocols
                    ◮    Two-phase locking
                    ◮    Snapshot isolation
          ◮    Consistency vs concurrency tradeoff
          ◮    ANSI SQL isolation levels
                                                 Dirty           Unrepeatable    Phantom
                         Isolation Level         Read               Read          Read
                   READ UNCOMMITTED           possible           possible       possible
                   READ COMMITTED             not possible       possible       possible
                   REPEATABLE READ            not possible       not possible   possible
                   SERIALIZABLE               not possible       not possible   not possible




CS5226: Sem 2, 2012/13                            Introduction                                 21
Tuning of memory
          ◮    How to optimize memory allocation?




                   Oracle Memory Model (Dageville & Zait, VLDB 2002)

CS5226: Sem 2, 2012/13                     Introduction                22
Data partitioning
          ◮    Increase data availability
          ◮    Decrease administrative cost
          ◮    Improve query performance




               Shared-nothing parallel DBMS (Hellerstein, et al., 2007)
CS5226: Sem 2, 2012/13                      Introduction                  23
References



    Additional Readings:
          ◮    J.M. Hellerstein, M. Stonebraker, J. Hamilton, Architecture of a
               Database System, Foundations and Trends in Databases, 1(2),
               2007, 141-259.




CS5226: Sem 2, 2012/13                       Introduction                         24

Más contenido relacionado

La actualidad más candente

IJCER (www.ijceronline.com) International Journal of computational Engineerin...
IJCER (www.ijceronline.com) International Journal of computational Engineerin...IJCER (www.ijceronline.com) International Journal of computational Engineerin...
IJCER (www.ijceronline.com) International Journal of computational Engineerin...ijceronline
 
Advanced computer architecture
Advanced computer architectureAdvanced computer architecture
Advanced computer architectureMd. Mahedi Mahfuj
 
Ultrasound Modular Architecture
Ultrasound Modular ArchitectureUltrasound Modular Architecture
Ultrasound Modular ArchitectureJose Miguel Moreno
 
003 properties of_pure_substance
003 properties of_pure_substance003 properties of_pure_substance
003 properties of_pure_substancephysics101
 
Hybrid TSR-PSR in nonlinear EH half duplex network: system performance analy...
Hybrid TSR-PSR in nonlinear EH half duplex  network: system performance analy...Hybrid TSR-PSR in nonlinear EH half duplex  network: system performance analy...
Hybrid TSR-PSR in nonlinear EH half duplex network: system performance analy...IJECEIAES
 

La actualidad más candente (6)

IJCER (www.ijceronline.com) International Journal of computational Engineerin...
IJCER (www.ijceronline.com) International Journal of computational Engineerin...IJCER (www.ijceronline.com) International Journal of computational Engineerin...
IJCER (www.ijceronline.com) International Journal of computational Engineerin...
 
cr1503
cr1503cr1503
cr1503
 
Advanced computer architecture
Advanced computer architectureAdvanced computer architecture
Advanced computer architecture
 
Ultrasound Modular Architecture
Ultrasound Modular ArchitectureUltrasound Modular Architecture
Ultrasound Modular Architecture
 
003 properties of_pure_substance
003 properties of_pure_substance003 properties of_pure_substance
003 properties of_pure_substance
 
Hybrid TSR-PSR in nonlinear EH half duplex network: system performance analy...
Hybrid TSR-PSR in nonlinear EH half duplex  network: system performance analy...Hybrid TSR-PSR in nonlinear EH half duplex  network: system performance analy...
Hybrid TSR-PSR in nonlinear EH half duplex network: system performance analy...
 

Destacado

J2EE - Practical Overview
J2EE - Practical OverviewJ2EE - Practical Overview
J2EE - Practical OverviewSvetlin Nakov
 
Evolving the Web into a Global Database - Advances and Applications.
Evolving the Web into a Global Database - Advances and Applications. Evolving the Web into a Global Database - Advances and Applications.
Evolving the Web into a Global Database - Advances and Applications. Chris Bizer
 
database slide
database slidedatabase slide
database slideAkhil Nair
 
Public Cloud Platforms for .NET Developers
Public Cloud Platforms for .NET DevelopersPublic Cloud Platforms for .NET Developers
Public Cloud Platforms for .NET DevelopersSvetlin Nakov
 
Writing High Quality Code in C#
Writing High Quality Code in C#Writing High Quality Code in C#
Writing High Quality Code in C#Svetlin Nakov
 
Nakov - .NET Framework Overview - English
Nakov - .NET Framework Overview - EnglishNakov - .NET Framework Overview - English
Nakov - .NET Framework Overview - EnglishSvetlin Nakov
 
RMAN best practices for RAC
RMAN best practices for RACRMAN best practices for RAC
RMAN best practices for RACSyed Hussain
 
14. Defining Classes
14. Defining Classes14. Defining Classes
14. Defining ClassesIntro C# Book
 
Payroll system
Payroll systemPayroll system
Payroll systemWirat Mojo
 
0. Course Introduction
0. Course Introduction0. Course Introduction
0. Course IntroductionIntro C# Book
 
Oracle database 12c new features
Oracle database 12c new featuresOracle database 12c new features
Oracle database 12c new featuresJakkrapat S.
 
Thesis about Computerized Payroll System for Barangay Hall, Dita
Thesis about Computerized Payroll System for Barangay Hall, DitaThesis about Computerized Payroll System for Barangay Hall, Dita
Thesis about Computerized Payroll System for Barangay Hall, DitaAcel Carl David O, Dolindo
 
HBase Vs Cassandra Vs MongoDB - Choosing the right NoSQL database
HBase Vs Cassandra Vs MongoDB - Choosing the right NoSQL databaseHBase Vs Cassandra Vs MongoDB - Choosing the right NoSQL database
HBase Vs Cassandra Vs MongoDB - Choosing the right NoSQL databaseEdureka!
 
Computerized payroll system
Computerized payroll systemComputerized payroll system
Computerized payroll systemFrancis Genavia
 
Payroll Management System
Payroll Management SystemPayroll Management System
Payroll Management SystemDheeraj Jha
 
Database Design Slide 1
Database Design Slide 1Database Design Slide 1
Database Design Slide 1ahfiki
 
Computer science project work
Computer science project workComputer science project work
Computer science project workrahulchamp2345
 
Payroll Management System SRS
Payroll Management System SRSPayroll Management System SRS
Payroll Management System SRSShubham Modi
 

Destacado (20)

J2EE - Practical Overview
J2EE - Practical OverviewJ2EE - Practical Overview
J2EE - Practical Overview
 
Evolving the Web into a Global Database - Advances and Applications.
Evolving the Web into a Global Database - Advances and Applications. Evolving the Web into a Global Database - Advances and Applications.
Evolving the Web into a Global Database - Advances and Applications.
 
database slide
database slidedatabase slide
database slide
 
database slide 1
database slide 1database slide 1
database slide 1
 
Public Cloud Platforms for .NET Developers
Public Cloud Platforms for .NET DevelopersPublic Cloud Platforms for .NET Developers
Public Cloud Platforms for .NET Developers
 
Writing High Quality Code in C#
Writing High Quality Code in C#Writing High Quality Code in C#
Writing High Quality Code in C#
 
Nakov - .NET Framework Overview - English
Nakov - .NET Framework Overview - EnglishNakov - .NET Framework Overview - English
Nakov - .NET Framework Overview - English
 
RMAN best practices for RAC
RMAN best practices for RACRMAN best practices for RAC
RMAN best practices for RAC
 
14. Defining Classes
14. Defining Classes14. Defining Classes
14. Defining Classes
 
Payroll system
Payroll systemPayroll system
Payroll system
 
0. Course Introduction
0. Course Introduction0. Course Introduction
0. Course Introduction
 
Oracle database 12c new features
Oracle database 12c new featuresOracle database 12c new features
Oracle database 12c new features
 
Thesis about Computerized Payroll System for Barangay Hall, Dita
Thesis about Computerized Payroll System for Barangay Hall, DitaThesis about Computerized Payroll System for Barangay Hall, Dita
Thesis about Computerized Payroll System for Barangay Hall, Dita
 
HBase Vs Cassandra Vs MongoDB - Choosing the right NoSQL database
HBase Vs Cassandra Vs MongoDB - Choosing the right NoSQL databaseHBase Vs Cassandra Vs MongoDB - Choosing the right NoSQL database
HBase Vs Cassandra Vs MongoDB - Choosing the right NoSQL database
 
Computerized payroll system
Computerized payroll systemComputerized payroll system
Computerized payroll system
 
Payroll Management System
Payroll Management SystemPayroll Management System
Payroll Management System
 
Database Design Slide 1
Database Design Slide 1Database Design Slide 1
Database Design Slide 1
 
Computer science project work
Computer science project workComputer science project work
Computer science project work
 
Payroll management
Payroll   managementPayroll   management
Payroll management
 
Payroll Management System SRS
Payroll Management System SRSPayroll Management System SRS
Payroll Management System SRS
 

Similar a Database slide

design-compiler.pdf
design-compiler.pdfdesign-compiler.pdf
design-compiler.pdfFrangoCamila
 
Profiling and optimization
Profiling and optimizationProfiling and optimization
Profiling and optimizationg3_nittala
 
OLTP+OLAP=HTAP
 OLTP+OLAP=HTAP OLTP+OLAP=HTAP
OLTP+OLAP=HTAPEDB
 
Quantum Annealing for Dirichlet Process Mixture Models with Applications to N...
Quantum Annealing for Dirichlet Process Mixture Models with Applications to N...Quantum Annealing for Dirichlet Process Mixture Models with Applications to N...
Quantum Annealing for Dirichlet Process Mixture Models with Applications to N...Shu Tanaka
 
pradeepbishtLecture13 div conq
pradeepbishtLecture13 div conqpradeepbishtLecture13 div conq
pradeepbishtLecture13 div conqPradeep Bisht
 
QR Factorizations and SVDs for Tall-and-skinny Matrices in MapReduce Architec...
QR Factorizations and SVDs for Tall-and-skinny Matrices in MapReduce Architec...QR Factorizations and SVDs for Tall-and-skinny Matrices in MapReduce Architec...
QR Factorizations and SVDs for Tall-and-skinny Matrices in MapReduce Architec...Austin Benson
 
Index Determination in DAEs using the Library indexdet and the ADOL-C Package...
Index Determination in DAEs using the Library indexdet and the ADOL-C Package...Index Determination in DAEs using the Library indexdet and the ADOL-C Package...
Index Determination in DAEs using the Library indexdet and the ADOL-C Package...Dagmar Monett
 
22d2 optimal assembly line balancing222
22d2 optimal assembly line balancing22222d2 optimal assembly line balancing222
22d2 optimal assembly line balancing222harkesh singh
 
lecture 41 cost optimization.pptx
lecture 41 cost optimization.pptxlecture 41 cost optimization.pptx
lecture 41 cost optimization.pptxSundaramyadav3
 
Formal Semantics of SQL and Cypher
Formal Semantics of SQL and CypherFormal Semantics of SQL and Cypher
Formal Semantics of SQL and CypheropenCypher
 
Predicting organic reaction outcomes with weisfeiler lehman network
Predicting organic reaction outcomes with weisfeiler lehman networkPredicting organic reaction outcomes with weisfeiler lehman network
Predicting organic reaction outcomes with weisfeiler lehman networkKazuki Fujikawa
 
Querying Temporal Databases via OWL 2 QL
Querying Temporal Databases via OWL 2 QLQuerying Temporal Databases via OWL 2 QL
Querying Temporal Databases via OWL 2 QLSzymon Klarman
 
Direct QR factorizations for tall-and-skinny matrices in MapReduce architectu...
Direct QR factorizations for tall-and-skinny matrices in MapReduce architectu...Direct QR factorizations for tall-and-skinny matrices in MapReduce architectu...
Direct QR factorizations for tall-and-skinny matrices in MapReduce architectu...Austin Benson
 
A Comparative Analysis on Parameters of Different Adder Topologies
A Comparative Analysis on Parameters of Different Adder TopologiesA Comparative Analysis on Parameters of Different Adder Topologies
A Comparative Analysis on Parameters of Different Adder TopologiesIRJET Journal
 
A Power Efficient Architecture for 2-D Discrete Wavelet Transform
A Power Efficient Architecture for 2-D Discrete Wavelet TransformA Power Efficient Architecture for 2-D Discrete Wavelet Transform
A Power Efficient Architecture for 2-D Discrete Wavelet TransformRahul Jain
 

Similar a Database slide (20)

design-compiler.pdf
design-compiler.pdfdesign-compiler.pdf
design-compiler.pdf
 
Profiling and optimization
Profiling and optimizationProfiling and optimization
Profiling and optimization
 
Yahoo search-study
Yahoo search-studyYahoo search-study
Yahoo search-study
 
OLTP+OLAP=HTAP
 OLTP+OLAP=HTAP OLTP+OLAP=HTAP
OLTP+OLAP=HTAP
 
05725150
0572515005725150
05725150
 
Quantum Annealing for Dirichlet Process Mixture Models with Applications to N...
Quantum Annealing for Dirichlet Process Mixture Models with Applications to N...Quantum Annealing for Dirichlet Process Mixture Models with Applications to N...
Quantum Annealing for Dirichlet Process Mixture Models with Applications to N...
 
pradeepbishtLecture13 div conq
pradeepbishtLecture13 div conqpradeepbishtLecture13 div conq
pradeepbishtLecture13 div conq
 
QR Factorizations and SVDs for Tall-and-skinny Matrices in MapReduce Architec...
QR Factorizations and SVDs for Tall-and-skinny Matrices in MapReduce Architec...QR Factorizations and SVDs for Tall-and-skinny Matrices in MapReduce Architec...
QR Factorizations and SVDs for Tall-and-skinny Matrices in MapReduce Architec...
 
l1.ppt
l1.pptl1.ppt
l1.ppt
 
Index Determination in DAEs using the Library indexdet and the ADOL-C Package...
Index Determination in DAEs using the Library indexdet and the ADOL-C Package...Index Determination in DAEs using the Library indexdet and the ADOL-C Package...
Index Determination in DAEs using the Library indexdet and the ADOL-C Package...
 
22d2 optimal assembly line balancing222
22d2 optimal assembly line balancing22222d2 optimal assembly line balancing222
22d2 optimal assembly line balancing222
 
lecture 41 cost optimization.pptx
lecture 41 cost optimization.pptxlecture 41 cost optimization.pptx
lecture 41 cost optimization.pptx
 
Formal Semantics of SQL and Cypher
Formal Semantics of SQL and CypherFormal Semantics of SQL and Cypher
Formal Semantics of SQL and Cypher
 
R Language Introduction
R Language IntroductionR Language Introduction
R Language Introduction
 
Predicting organic reaction outcomes with weisfeiler lehman network
Predicting organic reaction outcomes with weisfeiler lehman networkPredicting organic reaction outcomes with weisfeiler lehman network
Predicting organic reaction outcomes with weisfeiler lehman network
 
Querying Temporal Databases via OWL 2 QL
Querying Temporal Databases via OWL 2 QLQuerying Temporal Databases via OWL 2 QL
Querying Temporal Databases via OWL 2 QL
 
Direct QR factorizations for tall-and-skinny matrices in MapReduce architectu...
Direct QR factorizations for tall-and-skinny matrices in MapReduce architectu...Direct QR factorizations for tall-and-skinny matrices in MapReduce architectu...
Direct QR factorizations for tall-and-skinny matrices in MapReduce architectu...
 
8 query
8 query8 query
8 query
 
A Comparative Analysis on Parameters of Different Adder Topologies
A Comparative Analysis on Parameters of Different Adder TopologiesA Comparative Analysis on Parameters of Different Adder Topologies
A Comparative Analysis on Parameters of Different Adder Topologies
 
A Power Efficient Architecture for 2-D Discrete Wavelet Transform
A Power Efficient Architecture for 2-D Discrete Wavelet TransformA Power Efficient Architecture for 2-D Discrete Wavelet Transform
A Power Efficient Architecture for 2-D Discrete Wavelet Transform
 

Más de nep_test_account (18)

Doc2pages
Doc2pagesDoc2pages
Doc2pages
 
Doc2pages
Doc2pagesDoc2pages
Doc2pages
 
PDF TEST
PDF TESTPDF TEST
PDF TEST
 
Baboom!
Baboom!Baboom!
Baboom!
 
Baboom!
Baboom!Baboom!
Baboom!
 
uat
uatuat
uat
 
test pdf
test pdftest pdf
test pdf
 
08 linear classification_2
08 linear classification_208 linear classification_2
08 linear classification_2
 
linear classification
linear classificationlinear classification
linear classification
 
Lecture Notes in Machine Learning
Lecture Notes in Machine LearningLecture Notes in Machine Learning
Lecture Notes in Machine Learning
 
Induction of Decision Trees
Induction of Decision TreesInduction of Decision Trees
Induction of Decision Trees
 
Large-Scale Machine Learning at Twitter
Large-Scale Machine Learning at TwitterLarge-Scale Machine Learning at Twitter
Large-Scale Machine Learning at Twitter
 
A Few Useful Things to Know about Machine Learning
A Few Useful Things to Know about Machine LearningA Few Useful Things to Know about Machine Learning
A Few Useful Things to Know about Machine Learning
 
linear regression part 2
linear regression part 2linear regression part 2
linear regression part 2
 
Linear Regression
Linear RegressionLinear Regression
Linear Regression
 
Probability
ProbabilityProbability
Probability
 
Linear Algebra
Linear AlgebraLinear Algebra
Linear Algebra
 
Introduction
IntroductionIntroduction
Introduction
 

Database slide

  • 1. CS5226 Lecture 1 Introduction
  • 2. Database Tuning ◮ Make a database application run more quickly ◮ higher throughput ◮ lower response time ◮ Auto-tuning / self-tuning ◮ Better performance ◮ Easier manageability ◮ Query workload ◮ Online transaction processing (OLTP) ◮ Decision support systems (DSS) / Online analytical processing (OLAP) / Data warehousing CS5226: Sem 2, 2012/13 Introduction 2
  • 3. Anatomy of DBMS (Hellerstein, Stonebraker, Hamilton, 2007) CS5226: Sem 2, 2012/13 Introduction 3
  • 4. Query Optimization πX , Y , Z project X,Y,Z sort-merge join ⊲⊳R .B=T .B select R.X, S.Y, T.Z R.B = T.B from R, S, T hash join scan table where R.A = S.A ⊲⊳R .A=S.A T R.A = S.A for T and R.B = T.B R S scan index scan table on (A,Y) for R for S Internal Query Physical Query Representation Query Plan CS5226: Sem 2, 2012/13 Introduction 4
  • 5. Performance Tuning Knobs ◮ Schema tuning ◮ Query tuning ◮ Index & materialized view selection ◮ Statistics tuning ◮ Concurrency control tuning ◮ Data partitioning ◮ Memory tuning ◮ Hardware tuning CS5226: Sem 2, 2012/13 Introduction 5
  • 6. Schema Tuning CourseInfo Module Prof Room Building Time CS101 Turing LT 1 CS 0800 CS400 Turing LT 1 CS 1400 MU300 Bach LT 2 Math 1400 MA200 Newton LT 2 Math 1000 CS101 Turing LT 2 Math 1200 Schedule Course Room Time Module Facility Module Prof LT 1 0800 CS101 Room Building CS101 Turing LT 1 1400 CS400 LT 1 CS CS400 Turing LT 2 1400 MU200 LT 2 Math MU300 Bach LT 2 1000 MA200 MA200 Newton LT 2 1200 CS101 CS5226: Sem 2, 2012/13 Introduction 6
  • 7. Query Tuning Q1: select c.cname from Customer c where 1000 < (select sum(o.totalprice) from Order o where o.cust# = c.cust#) Q2: select c.cname from Customer c join Order o on c.cust# = o.cust# group by c.cust#, c.cname having 1000 < sum(o.totalprice) CS5226: Sem 2, 2012/13 Introduction 7
  • 8. Query Tuning (cont.) Q3: select c.cust#, c.cname, sum(o.totalprice) as T from Customer c join Order o on c.cust# = o.cust# group by c.cust#, cname Q4: select c.cust#, cname, T from customer c, (select cust#, sum(totalprice) as T from Order group by cust#) as o where c.cust# = o.cust# CS5226: Sem 2, 2012/13 Introduction 8
  • 9. Query Tuning (cont.) Q5: select distinct R.A, S.X from R, S where R.B = S.Y Q6: select R.A, S.X from R, S where R.B = S.Y CS5226: Sem 2, 2012/13 Introduction 9
  • 10. Index Tuning select A, B, C from R where 10 < A < 20 Access methods for selection queries: ◮ Table scan ◮ Use one or more indexes CS5226: Sem 2, 2012/13 Introduction 10
  • 11. B+-tree index 18 12 17 22 24 (Moe,10,55,180) (Larry,12,70,175) (Alice,17,48,175) (John,18,59,182) (Marcie,22,50,165) (Sally,24,48,169) (Curly,10,65,171) (Bob,15,60,178) (Lucy,17,45,170) (Charlie,20,69,173) (Linus,23,60,166) (Tom,25,56,176) Clustered index on (age) Relation R 59 name age weight height Moe 10 55 180 Curly 10 65 171 50 65 Larry 12 70 175 Bob 15 60 178 Alice 17 48 175 Lucy 17 45 170 (45, RID32) (50, RID51) (59, RID41) (65, RID12) John 18 59 182 (48, RID31) (55, RID11) (60, RID22) (69, RID42) Charlie 20 69 173 (48, RID61) (56, RID62) (60, RID52) (70, RID21) Marcie 22 50 165 Linus 23 60 166 Sally Tom 24 25 48 56 169 176 Unclustered index on (weight) CS5226: Sem 2, 2012/13 Introduction 11
  • 12. Index access methods ◮ Index scan ◮ Index seek [+ RID lookup ] ◮ Index intersection [+ RID lookup ] CS5226: Sem 2, 2012/13 Introduction 12
  • 13. Index scan select height from Student (175,48) (170,45) (178,60) (165,50, RID51) (170,45, RID32) (175,48, RID31) (178,60, RID22) (166,60, RID52) (171,65, RID12) (175,70, RID21) (180,55, RID11) (169,48, RID61) (173,69, RID42) (176,56, RID62) (182,59, RID41) Index on (height,weight) CS5226: Sem 2, 2012/13 Introduction 13
  • 14. Index seek select weight from Student where weight between 55 and 65 59 50 65 (45, RID32) (50, RID51) (59, RID41) (65, RID12) (48, RID31) (55, RID11) (60, RID22) (69, RID42) (48, RID61) (56, RID62) (60, RID52) (70, RID21) Index on (weight) CS5226: Sem 2, 2012/13 Introduction 14
  • 15. Index seek + RID lookups select weight select name from Student from Student where weight between 55 and 59 where weight between 55 and 59 and age ≥ 20 59 50 65 Index on (weight) (45, RID32) (50, RID51) (59, RID41) (65, RID12) (48, RID31) (55, RID11) (60, RID22) (69, RID42) (48, RID61) (56, RID62) (60, RID52) (70, RID21) (Moe,10,55,180) (Larry,12,70,175) (Alice,17,48,175) (Curly,10,65,171) (Bob,15,60,178) (Lucy,17,45,170) Data (Sally,24,48,169) (Marcie,22,50,165) (John,18,59,182) (Tom,25,56,176) (Linus,23,60,166) (Charlie,20,69,173) Pages CS5226: Sem 2, 2012/13 Introduction 15
  • 16. Index intersection select height, weight from Student where height between 164 and 170 and weight between 50 and 59 (175,48) 170 178 Index on (height) (165, RID51) (170, RID32) (175, RID31) (178, RID22) (166, RID52) (171, RID12) (175, RID21) (180, RID11) (169, RID61) (173, RID42) (176, RID62) (182, RID41) 59 50 65 Index on (weight) (45, RID32) (50, RID51) (59, RID41) (65, RID12) (48, RID31) (55, RID11) (60, RID22) (69, RID42) (48, RID61) (56, RID62) (60, RID52) (70, RID21) CS5226: Sem 2, 2012/13 Introduction 16
  • 17. Index Tuning Q1: select A, B, C from R where 10 < A < 20 and 20 < B < 100 Q2: select B, C, D from R where 50 < B < 100 and 60 < D < 80 CS5226: Sem 2, 2012/13 Introduction 17
  • 18. Materialized View Tuning Q1: select R.B from R, S where R.A = S.X and S.Y > 100 MV1: select R.A, R.B, S.X, S.Y from R, S where R.A = S.X Q1’: select B from MV1 where Y > 100 CS5226: Sem 2, 2012/13 Introduction 18
  • 19. Tuning of indexes & materialized views Given a query workload and a disk space constraint, what is the optimal configuration of indexes & materialized views to optimize the performance of the workload? CS5226: Sem 2, 2012/13 Introduction 19
  • 20. Tuning of statistics Examples of statistics: ◮ table cardinality ◮ statistics for each column: ◮ number of distinct values ◮ highest & lowest values ◮ frequent values ◮ data distribution statistics ◮ multi-column statistics Issues ◮ What statistics to collect? ◮ When to collect/refresh statistics? CS5226: Sem 2, 2012/13 Introduction 20
  • 21. Tuning of concurrency control ◮ Concurrency control protocols ◮ Two-phase locking ◮ Snapshot isolation ◮ Consistency vs concurrency tradeoff ◮ ANSI SQL isolation levels Dirty Unrepeatable Phantom Isolation Level Read Read Read READ UNCOMMITTED possible possible possible READ COMMITTED not possible possible possible REPEATABLE READ not possible not possible possible SERIALIZABLE not possible not possible not possible CS5226: Sem 2, 2012/13 Introduction 21
  • 22. Tuning of memory ◮ How to optimize memory allocation? Oracle Memory Model (Dageville & Zait, VLDB 2002) CS5226: Sem 2, 2012/13 Introduction 22
  • 23. Data partitioning ◮ Increase data availability ◮ Decrease administrative cost ◮ Improve query performance Shared-nothing parallel DBMS (Hellerstein, et al., 2007) CS5226: Sem 2, 2012/13 Introduction 23
  • 24. References Additional Readings: ◮ J.M. Hellerstein, M. Stonebraker, J. Hamilton, Architecture of a Database System, Foundations and Trends in Databases, 1(2), 2007, 141-259. CS5226: Sem 2, 2012/13 Introduction 24