SQL Query Writing Tips To Improve Performance in Db2 and Db2 Warehouse on Cloud

Size: px
Start display at page:

Download "SQL Query Writing Tips To Improve Performance in Db2 and Db2 Warehouse on Cloud"

Transcription

1 SQL Query Writing Tips To Improve Performance in Db2 and Db2 Warehouse on Cloud Calisto Zuzarte IBM St. Louis Db2 User s Group Tue, March 06, 2018 Db2 Warehouse Db2 Warehouse on Cloud Integrated Analytics System 1

2 Agenda Rewriting SQL to improve performance Queries with Outer Joins Queries with Aggregation Queries with High Cardinality Aggregation DISTINCT Queries with Correlated Subqueries Queries with OR predicates Queries With OR EXISTS / AND NOT EXISTS Predicates Queries with UNION ALL Queries With a Large Number of Joins

3 Queries With Outer Joins (1/4) - Reordering Inner Joins STLDIG Outer Joins do not filter rows Put them at the end of the statement or after expanding inner joins. SELECT.C10,.C20, T3.C30, T4.C40, T5.C50 FROM LEFT OUTER JOIN ON.C2 =.C2 LEFT OUTER JOIN T3 ON.C3 = T3.C3 INNER JOIN T4 ON.C4 = T4.C4 INNER JOIN T5 ON.C5 = T5.C5 WHERE T4.C0 = 2 SELECT.C10,.C20, T3.C30, T4.C40, T5.C50 FROM INNER JOIN T4 ON.C4 = T4.C4 INNER JOIN T5 ON.C5 = T5.C5 LEFT OUTER JOIN ON.C2 =.C2 LEFT OUTER JOIN T3 ON.C3 = T3.C3 WHERE T4.C0 = 2 Cost based automatic reordering may not be done without complete statistics information 3

4 Queries With Outer Joins (2/4) - Reordering Inner Joins STLDIG K 5K 5K T5 5K LOJ LOJ T3 LOJ T4 5K LOJ T3 5K T5 T4 4

5 Queries With Outer Joins (3/4) - Large NULL producing side Very large NULL producing side and small (or highly filtered) row producing side. In an MPP system, the NULL producing side may need to be broadcast or redistributed during the query SELECT.C1,.CX,.C2,.C3,.C20 FROM LEFT OUTER JOIN ON.C2 =.C2 WHERE.C0 = 2 SELECT.C1,.CX.C2,.C3,.C20 FROM LEFT OUTER JOIN (SELECT.* FROM, (SELECT DISTINCT C2 FROM WHERE.C0 = 2) WHERE.C2 =.C2 ) ON.C2 =.C2 WHERE.C0 = 2 5

6 Queries With Outer Joins (4/4) - Large NULL producing side LOJ 100M DTQ 100M ROJ DTQ 10K 10K 10K 10K DTQ 100M DTQ 5K 5K 10K Semi-Join 6

7 Queries with Aggregation (1/4) Reducing Aggregation Filtering joins are sometimes specified after aggregation STLDIG SELECT.C2,.C10,.C20,.C30, TX.S FROM INNER JOIN (SELECT.C2, SUM(.SALES) AS S FROM INNER JOIN T3 ON.C3 = T3.C3 GROUP BY.C2) TX ON.C2 =.C2 WHERE.C0 = 5 SELECT.C2,.C10,.C20,.C30, TX.S FROM INNER JOIN (SELECT.C2, SUM(.SALES) AS S FROM INNER JOIN T3 ON.C3 = T3.C3 INNER JOIN (SELECT DISTINCT.C2 FROM WHERE.C0 = 5 ) ON.C2 =.C2 GROUP BY.C2) TX ON.C2 =.C2 WHERE.C0 = 5 7

8 Queries with Aggregation (2/4) Reducing Aggregation STLDIG M 100M 100M GB 100K T3 100K 50M 100K 50M 100K T3 100M GB 50K 1M 1M 100K Semi-Join 8

9 Queries with Aggregation (3/4) - Eager Aggregation STLDIG A GROUP BY at the end of the query may have too much baggage SELECT.C20, T3.C30, T4.C40, T4.C41, T4.C42, T5.C50, SUM(.SALES) FROM INNER JOIN ON.C2 =.C2 INNER JOIN T3 ON.C3 = T3.C3 INNER JOIN T4 ON.C4 = T4.C4 INNER JOIN T5 ON.C5 = T5.C5 WHERE.C0 = 2 AND T3.C0 = MONTH( ) GROUP BY.C20, T3.C30, T4.C40, T4.C41, T4.C42, T5.C50 Filtering Joins Look up Joins with wide columns Or Expanding Joins SELECT TX.C20, TX.C30, T4.C40, T4.C41, T4.C42, T5.C50, SUM(TX.S) FROM (SELECT.C20, T3.C30,.C4,.C5, SUM(.SALES) AS S FROM INNER JOIN ON.C2 =.C2 INNER JOIN T3 ON.C3 = T3.C3 WHERE.C0 = 2 AND T3.C0 = MONTH( ) GROUP BY.C20, T3.C30,.C4,.C5 ) TX INNER JOIN T4 ON TX.C4 = T4.C4 INNER JOIN T5 ON TX.C5 = T5.C5 GROUP BY TX.C20, TX.C30, T4.C40, T4.C41, T4.C42, T5.C50 9

10 Queries with Aggregation (4/4) - Eager Aggregation 100M 50M T3 10K GB 200M T4 T5 Eager GROUP BY - Includes T4 and T5 Join columns - Excludes wide payload columns - Effective before expanding joins 100M 50M 500K 500K GB T3 10K GB T4 T5 10

11 Queries with DISTINCT (1/2) - Eliminating Duplicates Early Duplicate removal is sometimes deferred with DISTINCT subqueries SELECT.C10,.C20, T3.C30, T4.C40, T5.C50 FROM INNER JOIN ON.C2 =.C2 INNER JOIN T3 ON.C3 = T3.C3 INNER JOIN (SELECT DISTINCT C4, CX FROM T4 ) T4 ON.C4 = T4.C4 INNER JOIN (SELECT DISTINCT C5, CY FROM T5 ) T5 ON.C5 = T5.C5 WHERE SELECT.C10,.C20, T3.C30, T4.C40, T5.C50 FROM INNER JOIN ON.C2 =.C2 INNER JOIN T3 ON.C3 = T3.C3 INNER JOIN (SELECT C4, CX FROM T4 GROUP BY C4, CX) T4 ON.C4 = T4.C4 INNER JOIN (SELECT C5, CY FROM T5 GROUP BY C5, CY) T5 ON.C5 = T5.C5 WHERE 11

12 Queries with DISTINCT (2/2) - Eliminating Duplicates Early SORT SORT 10X 500M 5X 50M T5 GB T4 GB T5 T3 T3 T4 20M 20M GROUP BY forces duplicate removal 12

13 Queries With High Cardinality Aggregation DISTINCT (1/4) COUNT(DISTINCT C1) can be a memory hog 100s of millions of distinct values need to be kept in memory Cannot do a partial-final GROUP BY SELECT COUNT(DISTINCT C1) FROM GROUP BY C0 High number of distinct values Low number of distinct values or no GROUP BY SELECT COUNT(*) FROM (SELECT C0, C1 FROM GROUP BY C0, C1) AS T GROUP BY C0 Db2 may not do this automatically if costs are off Partial-Final GROUP BY is possible 13

14 Queries With High Cardinality Aggregation DISTINCT (2/4) 10 CD High count distinct values 10 C* 100M FGB 500M TQ 100M GB 250M TQ 500M 500M 250M PGB 14

15 Queries With High Cardinality Aggregation DISTINCT (3/4) Rewriting with multiple COUNT DISTINCTs may be a little more involved SELECT C0, COUNT(DISTINCT C1) CDC1, COUNT(DISTINCT C2) CDC2 FROM GROUP BY C0 SELECT C0, CDC1, CDC2 FROM ( SELECT COUNT(*) AS CDC1 FROM (SELECT C0, C1 FROM GROUP BY C0, C1) AS T GROUP BY C0) TX, ( SELECT COUNT(*) AS CDC2 FROM (SELECT C0, C2 FROM GROUP BY C0, C2) AS T GROUP BY C0) TY WHERE TX.C0 = TY.C0 15

16 Queries With High Cardinality Aggregation DISTINCT (4/4) 10 CD High count distinct values CDC1 10 CDC2 Each COUNT DISTINCT is done in a separate leg 500M 100M GB GB 20M 500M 500M Multiple scans required but better than a memory error 16

17 Queries With Correlated Subqueries (1/4) - Predicate Db2 query rewrite generally decorrelates the query SELECT * FROM VERSIONED_TBL WHERE.SALARY >= AND.DATE_COL >= (SELECT MIN(DATE_COL) FROM VERSIONED_TBL WHERE.EMP_ID =.EMP_ID) If not decorrelated with row tables an index helps. With column tables rewriting is generally better STLDIG SELECT * FROM VERSIONED_TBL, (SELECT.EMP_ID, MIN(DATE_COL) AS M FROM VERSIONED_TBL GROUP BY.EMP_ID) TX WHERE.SALARY >= AND.DATE_COL >= TX.M AND.EMP_ID = TX.EMP_ID) 17

18 Queries With Correlated Subqueries (2/4) - Predicate STLDIG scans required if no indexes GB SCAN GB SCAN 10K One scan needed 18

19 Queries With Correlated Subqueries (3/4) Select List STLDIG Aggregation subquery in the SELECT list (simple subqueries handled) SELECT C1, (SELECT MAX(C2) FROM, T3 WHERE.C1 =.C1 AND.C3 = T3.C3 ) as C2, C3 FROM WHERE.C0 > 10 SELECT.C1, TX.MAXC2 AS C2,.C3 FROM LEFT OUTER JOIN (SELECT C1, MAX(C2) AS MAXC2 FROM, T3 WHERE.C3 = T3.C3 GROUP BY C1 ) TX ON (.C1 = TX.C1) WHERE.C0 > 10 Use a WITH clause for TX if there are multiple similar SELECT list aggregation subqueries 19

20 Queries With Correlated Subqueries (4/4) Select List STLDIG scans required if no indexes GB SCAN LOJ GB SCAN 10K One scan needed 20

21 Queries With OR Predicates (1/6) - OR Join Predicates STLDIG OR Join predicates cannot be processed by a Hash Join Nested Loop Joins work well with row tables and indexes Column oriented tables perform better with a UNION DISTINCT must be present to transform SELECT DISTINCT.C1,.C2,.C3,.CX FROM, WHERE ((.C6 =.C2 and.c3 IN ('1', 2') ) OR (.C7 =.C2 and.c3 NOT IN IN ('1', 2') ) ) SELECT.C1,.C2,.C3,.CX FROM (SELECT.C1,.C2,.C3,.CX FROM, WHERE.C6 =.C2 and.c3 IN ('1', 2') UNION SELECT.C1,.C2,.C3,.CX FROM, WHERE.C7 =.C2 and.c3 NOT IN ('1', 2') 21

22 Queries With OR Predicates (2/6) - OR Join Predicates STLDIG OR predicate applied to cartesian join (nested loop join) 100M 10K UNION Each branch of the UNION has a simple equality predicate join and can use a hash join 22

23 Queries With OR Predicates (3/6) OR EXISTS / AND NOT EXISTS If no complexity, Db2 tries to use Left Outer Joins for better performance The following example is with NOT EXISTS AND NOT EXISTS IS NOT NULL is used for the EXISTS OR EXISTS transformation SELECT.C1,.C2,.C3 FROM WHERE NOT EXISTS (SELECT 1 FROM WHERE.C2 =.C2) AND NOT EXISTS (SELECT 1 FROM T3 WHERE.C3 = T3.C3) SELECT.C1,.C2,.C3 FROM LEFT OUTER JOIN ON.C2 =.C2 LEFT OUTER JOIN T3 ON.C3 = T3.C3 WHERE.C2 IS NULL AND T3.C3 IS NULL 23

24 Queries With OR Predicates (2/3) - OR EXISTS Subqueries OR EXISTS predicate may be applied as a FILTER predicate FILTER OR predicate uses IS NULL to test whether the values EXIST FILTER LOJ 100M SCAN SCAN 10K 5K LOJ T3 T3 24

25 Queries With OR Predicates (5/6) - Alternative OR To UNION Db2 handles this particular scenario. Consider rewriting if still correlated and slow. Scans and joins are repeated Needs DISTINCT to be equivalent SELECT DISTINCT.C1,.C2,.C3 FROM WHERE.C0 = 0 OR EXISTS (SELECT 1 FROM WHERE.C2 =.C2) SELECT.C1,.C2,.C3 FROM (SELECT.C1,.C2,.C3 FROM WHERE.C0 = 0 UNION SELECT.C1,.C2,.C3 FROM WHERE EXISTS (SELECT 1 FROM WHERE.C1 =.C2) ) 25

26 Queries With OR Predicates (5/6) - Alternative OR To UNION OR EXISTS predicate may be applied as a FILTER predicate FILTER UNION This branch has the EXISTS predicate converted into a join 100M SCAN 10K 26

27 Queries With UNION ALL (1/2) - UNION ALL over tiny tables Db2 tries to push Joins through a UNION ALL Great with UNION ALL over row oriented Fact Tables UNION ALL over small dimension tables may not perform on column oriented tables SELECT FROM F1 INNER JOIN D2 ON F1.C2 = D2.C2 INNER JOIN D3 ON F1.C3 = D3.C3 INNER JOIN D4_UNION_ALL D4 ON F1.C4 = D4.C4 SELECT FROM F1 INNER JOIN D2 ON F1.C2 = D2.C2 INNER JOIN D3 ON F1.C3 = D3.C3 INNER JOIN (SELECT * FROM (SELECT, RAND( ) R FROM D4_UNION_ALL ) UA WHERE R >= 0 ) D4 ON F1.C4 = D4.C4 27

28 Queries With UNION ALL (2/2) - UNION ALL over tiny tables UNION N Join Pushdown through UNION results in multiple scans of the fact table D4 UNION N D5 D3 D4 D5 D3 D3 F1 D2 F1 D2 F1 D2 RAND( ) prevents the pushdown 28

29 Queries With a Large Number of Joins Excessive Compile Time? Consider GROUP BY instead of DISTINCT to break up a query block. SELECT.C10,.C20, T3.C30,, T5.CX 5.C150 FROM INNER JOIN ON.C2 =.C2 INNER JOIN T3 ON.C3 = T3.C3 INNER JOIN (SELECT DISTINCT T7.C7, T9.CX FROM T7, T8, T9 WHERE ) TX ON.C7 = TX.C7 INNER JOIN 5 ON.C15 = 5.C15 WHERE SELECT.C10,.C20, T3.C30,, T5.CX 5.C150 FROM INNER JOIN ON.C2 =.C2 INNER JOIN T3 ON.C3 = T3.C3 INNER JOIN (SELECT T7.C7, T9.CX FROM T7, T8, T9 WHERE GROUP BY T7.C7, T9.CX) TX ON.C7 = TX.C7 INNER JOIN 5 ON.C15 = 5.C15 WHERE Other option : breaking up the query using DGTTs, 29

30 Queries With UNION ALL (2/2) - UNION ALL over tiny tables Excessive compile time? GB T4 T9 T4 T3 T7 T8 T3 T9 T7 T8 Tables below the GROUP BY not compiled with the rest of the query 30

31 Calisto Zuzarte IBM SQL Query Writing Tips To Improve Performance in Db2 and Db2 Warehouse on Cloud 31

Querying Data with Transact SQL

Querying Data with Transact SQL Course 20761A: Querying Data with Transact SQL Course details Course Outline Module 1: Introduction to Microsoft SQL Server 2016 This module introduces SQL Server, the versions of SQL Server, including

More information

Querying Data with Transact-SQL

Querying Data with Transact-SQL Course 20761A: Querying Data with Transact-SQL Page 1 of 5 Querying Data with Transact-SQL Course 20761A: 2 days; Instructor-Led Introduction The main purpose of this 2 day instructor led course is to

More information

Querying Data with Transact-SQL

Querying Data with Transact-SQL Querying Data with Transact-SQL Course: 20761 Course Details Audience(s): IT Professional(s) Technology: Microsoft SQL Server 2016 Duration: 24 HRs. ABOUT THIS COURSE This course is designed to introduce

More information

Querying Data with Transact SQL Microsoft Official Curriculum (MOC 20761)

Querying Data with Transact SQL Microsoft Official Curriculum (MOC 20761) Querying Data with Transact SQL Microsoft Official Curriculum (MOC 20761) Course Length: 3 days Course Delivery: Traditional Classroom Online Live MOC on Demand Course Overview The main purpose of this

More information

MANAGING DATA(BASES) USING SQL (NON-PROCEDURAL SQL, X401.9)

MANAGING DATA(BASES) USING SQL (NON-PROCEDURAL SQL, X401.9) Technology & Information Management Instructor: Michael Kremer, Ph.D. Class 6 Professional Program: Data Administration and Management MANAGING DATA(BASES) USING SQL (NON-PROCEDURAL SQL, X401.9) AGENDA

More information

Querying Data with Transact-SQL (20761)

Querying Data with Transact-SQL (20761) Querying Data with Transact-SQL (20761) Formato do curso: Presencial e Live Training Preço: 1630 Nível: Iniciado Duração: 35 horas The main purpose of this 5 day instructor led course is to give students

More information

Course Modules for MCSA: SQL Server 2016 Database Development Training & Certification Course:

Course Modules for MCSA: SQL Server 2016 Database Development Training & Certification Course: Course Modules for MCSA: SQL Server 2016 Database Development Training & Certification Course: 20762C Developing SQL 2016 Databases Module 1: An Introduction to Database Development Introduction to the

More information

Querying Microsoft SQL Server 2014

Querying Microsoft SQL Server 2014 Querying Microsoft SQL Server 2014 Course: 20461 Course Details Audience(s): IT Professional(s) Technology: Microsoft SQL Server 2014 Duration: 40 Hours ABOUT THIS COURSE This forty hours of instructor-led

More information

20461: Querying Microsoft SQL Server 2014 Databases

20461: Querying Microsoft SQL Server 2014 Databases Course Outline 20461: Querying Microsoft SQL Server 2014 Databases Module 1: Introduction to Microsoft SQL Server 2014 This module introduces the SQL Server platform and major tools. It discusses editions,

More information

[AVNICF-MCSASQL2012]: NICF - Microsoft Certified Solutions Associate (MCSA): SQL Server 2012

[AVNICF-MCSASQL2012]: NICF - Microsoft Certified Solutions Associate (MCSA): SQL Server 2012 [AVNICF-MCSASQL2012]: NICF - Microsoft Certified Solutions Associate (MCSA): SQL Server 2012 Length Delivery Method : 5 Days : Instructor-led (Classroom) Course Overview Participants will learn technical

More information

Copyright 2016 Ramez Elmasri and Shamkant B. Navathe

Copyright 2016 Ramez Elmasri and Shamkant B. Navathe CHAPTER 19 Query Optimization Introduction Query optimization Conducted by a query optimizer in a DBMS Goal: select best available strategy for executing query Based on information available Most RDBMSs

More information

Querying Data with Transact-SQL

Querying Data with Transact-SQL Course Code: M20761 Vendor: Microsoft Course Overview Duration: 5 RRP: 2,177 Querying Data with Transact-SQL Overview This course is designed to introduce students to Transact-SQL. It is designed in such

More information

COURSE OUTLINE MOC 20461: QUERYING MICROSOFT SQL SERVER 2014

COURSE OUTLINE MOC 20461: QUERYING MICROSOFT SQL SERVER 2014 COURSE OUTLINE MOC 20461: QUERYING MICROSOFT SQL SERVER 2014 MODULE 1: INTRODUCTION TO MICROSOFT SQL SERVER 2014 This module introduces the SQL Server platform and major tools. It discusses editions, versions,

More information

Project. Building a Simple Query Optimizer with Performance Evaluation Experiment on Query Rewrite Optimization

Project. Building a Simple Query Optimizer with Performance Evaluation Experiment on Query Rewrite Optimization Project CIS611 SS Chung Building a Simple Query Optimizer with Performance Evaluation Experiment on Query Rewrite Optimization This project is to simulate a simple Query Optimizer that: 1. Evaluates query

More information

Querying Microsoft SQL Server 2008/2012

Querying Microsoft SQL Server 2008/2012 Querying Microsoft SQL Server 2008/2012 Course 10774A 5 Days Instructor-led, Hands-on Introduction This 5-day instructor led course provides students with the technical skills required to write basic Transact-SQL

More information

Subquery: There are basically three types of subqueries are:

Subquery: There are basically three types of subqueries are: Subquery: It is also known as Nested query. Sub queries are queries nested inside other queries, marked off with parentheses, and sometimes referred to as "inner" queries within "outer" queries. Subquery

More information

T-SQL Training: T-SQL for SQL Server for Developers

T-SQL Training: T-SQL for SQL Server for Developers Duration: 3 days T-SQL Training Overview T-SQL for SQL Server for Developers training teaches developers all the Transact-SQL skills they need to develop queries and views, and manipulate data in a SQL

More information

MCSA SQL SERVER 2012

MCSA SQL SERVER 2012 MCSA SQL SERVER 2012 1. Course 10774A: Querying Microsoft SQL Server 2012 Course Outline Module 1: Introduction to Microsoft SQL Server 2012 Introducing Microsoft SQL Server 2012 Getting Started with SQL

More information

SQL Data Query Language

SQL Data Query Language SQL Data Query Language André Restivo 1 / 68 Index Introduction Selecting Data Choosing Columns Filtering Rows Set Operators Joining Tables Aggregating Data Sorting Rows Limiting Data Text Operators Nested

More information

After completing this course, participants will be able to:

After completing this course, participants will be able to: Querying SQL Server T h i s f i v e - d a y i n s t r u c t o r - l e d c o u r s e p r o v i d e s p a r t i c i p a n t s w i t h t h e t e c h n i c a l s k i l l s r e q u i r e d t o w r i t e b a

More information

20461: Querying Microsoft SQL Server

20461: Querying Microsoft SQL Server 20461: Querying Microsoft SQL Server Length: 5 days Audience: IT Professionals Level: 300 OVERVIEW This 5 day instructor led course provides students with the technical skills required to write basic Transact

More information

DB2 9 for z/os Selected Query Performance Enhancements

DB2 9 for z/os Selected Query Performance Enhancements Session: C13 DB2 9 for z/os Selected Query Performance Enhancements James Guo IBM Silicon Valley Lab May 10, 2007 10:40 a.m. 11:40 a.m. Platform: DB2 for z/os 1 Table of Content Cross Query Block Optimization

More information

Querying Microsoft SQL Server (MOC 20461C)

Querying Microsoft SQL Server (MOC 20461C) Querying Microsoft SQL Server 2012-2014 (MOC 20461C) Course 21461 40 Hours This 5-day instructor led course provides students with the technical skills required to write basic Transact-SQL queries for

More information

SQL QUERIES. CS121: Relational Databases Fall 2017 Lecture 5

SQL QUERIES. CS121: Relational Databases Fall 2017 Lecture 5 SQL QUERIES CS121: Relational Databases Fall 2017 Lecture 5 SQL Queries 2 SQL queries use the SELECT statement General form is: SELECT A 1, A 2,... FROM r 1, r 2,... WHERE P; r i are the relations (tables)

More information

AVANTUS TRAINING PTE LTD

AVANTUS TRAINING PTE LTD [MS20461]: Querying Microsoft SQL Server 2014 Length : 5 Days Audience(s) : IT Professionals Level : 300 Technology : SQL Server Delivery Method : Instructor-led (Classroom) Course Overview This 5-day

More information

Database System Concepts

Database System Concepts Chapter 14: Optimization Departamento de Engenharia Informática Instituto Superior Técnico 1 st Semester 2007/2008 Slides (fortemente) baseados nos slides oficiais do livro c Silberschatz, Korth and Sudarshan.

More information

Query Optimization. Introduction to Databases CompSci 316 Fall 2018

Query Optimization. Introduction to Databases CompSci 316 Fall 2018 Query Optimization Introduction to Databases CompSci 316 Fall 2018 2 Announcements (Tue., Nov. 20) Homework #4 due next in 2½ weeks No class this Thu. (Thanksgiving break) No weekly progress update due

More information

Advanced Oracle Performance Troubleshooting. Query Transformations Randolf Geist

Advanced Oracle Performance Troubleshooting. Query Transformations Randolf Geist Advanced Oracle Performance Troubleshooting Query Transformations Randolf Geist http://oracle-randolf.blogspot.com/ http://www.sqltools-plusplus.org:7676/ info@sqltools-plusplus.org Independent Consultant

More information

"Charting the Course... MOC C: Querying Data with Transact-SQL. Course Summary

Charting the Course... MOC C: Querying Data with Transact-SQL. Course Summary Course Summary Description This course is designed to introduce students to Transact-SQL. It is designed in such a way that the first three days can be taught as a course to students requiring the knowledge

More information

Query optimization. Elena Baralis, Silvia Chiusano Politecnico di Torino. DBMS Architecture D B M G. Database Management Systems. Pag.

Query optimization. Elena Baralis, Silvia Chiusano Politecnico di Torino. DBMS Architecture D B M G. Database Management Systems. Pag. Database Management Systems DBMS Architecture SQL INSTRUCTION OPTIMIZER MANAGEMENT OF ACCESS METHODS CONCURRENCY CONTROL BUFFER MANAGER RELIABILITY MANAGEMENT Index Files Data Files System Catalog DATABASE

More information

Querying Microsoft SQL Server

Querying Microsoft SQL Server Querying Microsoft SQL Server 20461D; 5 days, Instructor-led Course Description This 5-day instructor led course provides students with the technical skills required to write basic Transact SQL queries

More information

COURSE OUTLINE: Querying Microsoft SQL Server

COURSE OUTLINE: Querying Microsoft SQL Server Course Name 20461 Querying Microsoft SQL Server Course Duration 5 Days Course Structure Instructor-Led (Classroom) Course Overview This 5-day instructor led course provides students with the technical

More information

Microsoft Querying Data with Transact-SQL - Performance Course

Microsoft Querying Data with Transact-SQL - Performance Course 1800 ULEARN (853 276) www.ddls.com.au Microsoft 20761 - Querying Data with Transact-SQL - Performance Course Length 4 days Price $4290.00 (inc GST) Version C Overview This course is designed to introduce

More information

Querying Microsoft SQL Server

Querying Microsoft SQL Server Querying Microsoft SQL Server Course 20461D 5 Days Instructor-led, Hands-on Course Description This 5-day instructor led course is designed for customers who are interested in learning SQL Server 2012,

More information

20761 Querying Data with Transact SQL

20761 Querying Data with Transact SQL Course Overview The main purpose of this course is to give students a good understanding of the Transact-SQL language which is used by all SQL Server-related disciplines; namely, Database Administration,

More information

Querying Data with Transact-SQL

Querying Data with Transact-SQL Querying Data with Transact-SQL Código del curso: 20761 Duración: 5 días Acerca de este curso This course is designed to introduce students to Transact-SQL. It is designed in such a way that the first

More information

Course 20461C: Querying Microsoft SQL Server

Course 20461C: Querying Microsoft SQL Server Course 20461C: Querying Microsoft SQL Server Audience Profile About this Course This course is the foundation for all SQL Serverrelated disciplines; namely, Database Administration, Database Development

More information

QUERYING MICROSOFT SQL SERVER COURSE OUTLINE. Course: 20461C; Duration: 5 Days; Instructor-led

QUERYING MICROSOFT SQL SERVER COURSE OUTLINE. Course: 20461C; Duration: 5 Days; Instructor-led CENTER OF KNOWLEDGE, PATH TO SUCCESS Website: QUERYING MICROSOFT SQL SERVER Course: 20461C; Duration: 5 Days; Instructor-led WHAT YOU WILL LEARN This 5-day instructor led course provides students with

More information

Course Outline. Querying Data with Transact-SQL Course 20761B: 5 days Instructor Led

Course Outline. Querying Data with Transact-SQL Course 20761B: 5 days Instructor Led Querying Data with Transact-SQL Course 20761B: 5 days Instructor Led About this course This course is designed to introduce students to Transact-SQL. It is designed in such a way that the first three days

More information

Querying Microsoft SQL Server 2012/2014

Querying Microsoft SQL Server 2012/2014 Page 1 of 14 Overview This 5-day instructor led course provides students with the technical skills required to write basic Transact-SQL queries for Microsoft SQL Server 2014. This course is the foundation

More information

Querying Data with Transact-SQL

Querying Data with Transact-SQL Querying Data with Transact-SQL 20761B; 5 Days; Instructor-led Course Description This course is designed to introduce students to Transact-SQL. It is designed in such a way that the first three days can

More information

Interview Questions on DBMS and SQL [Compiled by M V Kamal, Associate Professor, CSE Dept]

Interview Questions on DBMS and SQL [Compiled by M V Kamal, Associate Professor, CSE Dept] Interview Questions on DBMS and SQL [Compiled by M V Kamal, Associate Professor, CSE Dept] 1. What is DBMS? A Database Management System (DBMS) is a program that controls creation, maintenance and use

More information

20761B: QUERYING DATA WITH TRANSACT-SQL

20761B: QUERYING DATA WITH TRANSACT-SQL ABOUT THIS COURSE This 5 day course is designed to introduce students to Transact-SQL. It is designed in such a way that the first three days can be taught as a course to students requiring the knowledge

More information

Oracle Database: Introduction to SQL Ed 2

Oracle Database: Introduction to SQL Ed 2 Oracle University Contact Us: +40 21 3678820 Oracle Database: Introduction to SQL Ed 2 Duration: 5 Days What you will learn This Oracle Database 12c: Introduction to SQL training helps you write subqueries,

More information

RDBMS- Day 4. Grouped results Relational algebra Joins Sub queries. In today s session we will discuss about the concept of sub queries.

RDBMS- Day 4. Grouped results Relational algebra Joins Sub queries. In today s session we will discuss about the concept of sub queries. RDBMS- Day 4 Grouped results Relational algebra Joins Sub queries In today s session we will discuss about the concept of sub queries. Grouped results SQL - Using GROUP BY Related rows can be grouped together

More information

Querying Microsoft SQL Server

Querying Microsoft SQL Server Querying Microsoft SQL Server Duration: 5 Days (08:30-16:00) Overview: This course provides students with the technical skills required to write basic Transact-SQL queries for Microsoft SQL Server. This

More information

20461D: Querying Microsoft SQL Server

20461D: Querying Microsoft SQL Server 20461D: Querying Microsoft SQL Server Course Details Course Code: Duration: Notes: 20461D 5 days This course syllabus should be used to determine whether the course is appropriate for the students, based

More information

Querying Data with Transact-SQL

Querying Data with Transact-SQL Querying Data with Transact-SQL Course 20761C 5 Days Instructor-led, Hands on Course Information The main purpose of the course is to give students a good understanding of the Transact- SQL language which

More information

DB2 12 for z/os Optimizer Sneak Peek

DB2 12 for z/os Optimizer Sneak Peek DB2 12 for z/os Optimizer Sneak Peek Terry Purcell IBM Silicon Valley Lab Session Code: @Alabama Tuesday Oct 4th Platform: DB2 for z/os Disclaimer Information regarding potential future products is intended

More information

1 Writing Basic SQL SELECT Statements 2 Restricting and Sorting Data

1 Writing Basic SQL SELECT Statements 2 Restricting and Sorting Data 1 Writing Basic SQL SELECT Statements Objectives 1-2 Capabilities of SQL SELECT Statements 1-3 Basic SELECT Statement 1-4 Selecting All Columns 1-5 Selecting Specific Columns 1-6 Writing SQL Statements

More information

Microsoft Querying Microsoft SQL Server 2014

Microsoft Querying Microsoft SQL Server 2014 1800 ULEARN (853 276) www.ddls.com.au Microsoft 20461 - Querying Microsoft SQL Server 2014 Length 5 days Price $4290.00 (inc GST) Version D Overview Please note: Microsoft have released a new course which

More information

"Charting the Course to Your Success!" MOC D Querying Microsoft SQL Server Course Summary

Charting the Course to Your Success! MOC D Querying Microsoft SQL Server Course Summary Course Summary Description This 5-day instructor led course provides students with the technical skills required to write basic Transact-SQL queries for Microsoft SQL Server 2014. This course is the foundation

More information

Oracle Syllabus Course code-r10605 SQL

Oracle Syllabus Course code-r10605 SQL Oracle Syllabus Course code-r10605 SQL Writing Basic SQL SELECT Statements Basic SELECT Statement Selecting All Columns Selecting Specific Columns Writing SQL Statements Column Heading Defaults Arithmetic

More information

Querying Data with Transact-SQL

Querying Data with Transact-SQL Querying Data with Transact-SQL Duration: 5 Days Course Code: M20761 Overview: This course is designed to introduce students to Transact-SQL. It is designed in such a way that the first three days can

More information

Querying Microsoft SQL Server

Querying Microsoft SQL Server Course Code: M20461 Vendor: Microsoft Course Overview Duration: 5 RRP: POA Querying Microsoft SQL Server Overview This 5-day instructor led course provides delegates with the technical skills required

More information

Querying Microsoft SQL Server

Querying Microsoft SQL Server 20461 - Querying Microsoft SQL Server Duration: 5 Days Course Price: $2,975 Software Assurance Eligible Course Description About this course This 5-day instructor led course provides students with the

More information

Teradata SQL Features Overview Version

Teradata SQL Features Overview Version Table of Contents Teradata SQL Features Overview Version 14.10.0 Module 0 - Introduction Course Objectives... 0-4 Course Description... 0-6 Course Content... 0-8 Module 1 - Teradata Studio Features Optimize

More information

Querying Microsoft SQL Server 2014

Querying Microsoft SQL Server 2014 Querying Microsoft SQL Server 2014 Código del curso: 20461 Duración: 5 días Acerca de este curso This 5 day instructor led course provides students with the technical skills required to write basic Transact

More information

Querying Data with Transact-SQL (761)

Querying Data with Transact-SQL (761) Querying Data with Transact-SQL (761) Manage data with Transact-SQL Create Transact-SQL SELECT queries Identify proper SELECT query structure, write specific queries to satisfy business requirements, construct

More information

Database Systems: Design, Implementation, and Management Tenth Edition. Chapter 8 Advanced SQL

Database Systems: Design, Implementation, and Management Tenth Edition. Chapter 8 Advanced SQL Database Systems: Design, Implementation, and Management Tenth Edition Chapter 8 Advanced SQL SQL Join Operators Join operation merges rows from two tables and returns the rows with one of the following:

More information

Performance Optimization for Informatica Data Services ( Hotfix 3)

Performance Optimization for Informatica Data Services ( Hotfix 3) Performance Optimization for Informatica Data Services (9.5.0-9.6.1 Hotfix 3) 1993-2015 Informatica Corporation. No part of this document may be reproduced or transmitted in any form, by any means (electronic,

More information

Querying Data with Transact-SQL

Querying Data with Transact-SQL Querying Data with Transact-SQL General Description This course is designed to introduce students to Transact-SQL. It is designed in such a way that the first three days can be taught as a course to students

More information

Duration Level Technology Delivery Method Training Credits. Classroom ILT 5 Days Intermediate SQL Server

Duration Level Technology Delivery Method Training Credits. Classroom ILT 5 Days Intermediate SQL Server NE-20761C Querying with Transact-SQL Summary Duration Level Technology Delivery Method Training Credits Classroom ILT 5 Days Intermediate SQL Virtual ILT On Demand SATV Introduction This course is designed

More information

CSE 344 MAY 7 TH EXAM REVIEW

CSE 344 MAY 7 TH EXAM REVIEW CSE 344 MAY 7 TH EXAM REVIEW EXAMINATION STATIONS Exam Wednesday 9:30-10:20 One sheet of notes, front and back Practice solutions out after class Good luck! EXAM LENGTH Production v. Verification Practice

More information

SQL Data Querying and Views

SQL Data Querying and Views Course A7B36DBS: Database Systems Lecture 04: SQL Data Querying and Views Martin Svoboda Faculty of Electrical Engineering, Czech Technical University in Prague Outline SQL Data manipulation SELECT queries

More information

INTERMEDIATE SQL GOING BEYOND THE SELECT. Created by Brian Duffey

INTERMEDIATE SQL GOING BEYOND THE SELECT. Created by Brian Duffey INTERMEDIATE SQL GOING BEYOND THE SELECT Created by Brian Duffey WHO I AM Brian Duffey 3 years consultant at michaels, ross, and cole 9+ years SQL user What have I used SQL for? ROADMAP Introduction 1.

More information

CMP-3440 Database Systems

CMP-3440 Database Systems CMP-3440 Database Systems Relational DB Languages Relational Algebra, Calculus, SQL Lecture 05 zain 1 Introduction Relational algebra & relational calculus are formal languages associated with the relational

More information

Language. f SQL. Larry Rockoff COURSE TECHNOLOGY. Kingdom United States. Course Technology PTR. A part ofcenqaqe Learninq

Language. f SQL. Larry Rockoff COURSE TECHNOLOGY. Kingdom United States. Course Technology PTR. A part ofcenqaqe Learninq Language f SQL Larry Rockoff Course Technology PTR A part ofcenqaqe Learninq *, COURSE TECHNOLOGY!» CENGAGE Learning- Australia Brazil Japan Korea Mexico Singapore Spain United Kingdom United States '

More information

20761C: Querying Data with Transact-SQL

20761C: Querying Data with Transact-SQL 20761C: Querying Data with Transact-SQL Course Details Course Code: Duration: Notes: 20761C 5 days This course syllabus should be used to determine whether the course is appropriate for the students, based

More information

Welcome to the presentation. Thank you for taking your time for being here.

Welcome to the presentation. Thank you for taking your time for being here. Welcome to the presentation. Thank you for taking your time for being here. In this presentation, my goal is to share with you 10 practical points that a single partitioned DBA needs to know to get head

More information

SEIZE THE DATA SEIZE THE DATA. 2015

SEIZE THE DATA SEIZE THE DATA. 2015 1 Copyright 2015 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice. Advanced Projection Design Herb Collins, Vertica Training August 10, 2015

More information

Performance Issue : More than 30 sec to load. Design OK, No complex calculation. 7 tables joined, 500+ millions rows

Performance Issue : More than 30 sec to load. Design OK, No complex calculation. 7 tables joined, 500+ millions rows Bienvenue Nicolas Performance Issue : More than 30 sec to load Design OK, No complex calculation 7 tables joined, 500+ millions rows Denormalize, Materialized Views, Columnstore Index Less than 5 sec to

More information

Db2 12 for z/os Optimizer Update

Db2 12 for z/os Optimizer Update IBM & IDUG 2018 Data Tech Summit Db2 12 for z/os Optimizer Update Terry Purcell IBM Dec 12 th, 2018 #Db2World #IDUGDb2 #IBMDb2 IBM z Analytics Agenda Db2 12 Performance Focus UNION ALL & Outer Join Enhancements

More information

MTA Database Administrator Fundamentals Course

MTA Database Administrator Fundamentals Course MTA Database Administrator Fundamentals Course Session 1 Section A: Database Tables Tables Representing Data with Tables SQL Server Management Studio Section B: Database Relationships Flat File Databases

More information

Principles of Data Management. Lecture #12 (Query Optimization I)

Principles of Data Management. Lecture #12 (Query Optimization I) Principles of Data Management Lecture #12 (Query Optimization I) Instructor: Mike Carey mjcarey@ics.uci.edu Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 1 Today s Notable News v B+ tree

More information

Three types of sub queries are supported in SQL are Scalar, Row and Table sub queries.

Three types of sub queries are supported in SQL are Scalar, Row and Table sub queries. SQL Sub-Queries What are Sub queries? SQL Sub queries are the queries which are embedded inside another query. The embedded queries are called as INNER query & container query is called as OUTER query.

More information

DB2 SQL Class Outline

DB2 SQL Class Outline DB2 SQL Class Outline The Basics of SQL Introduction Finding Your Current Schema Setting Your Default SCHEMA SELECT * (All Columns) in a Table SELECT Specific Columns in a Table Commas in the Front or

More information

Unit Assessment Guide

Unit Assessment Guide Unit Assessment Guide Unit Details Unit code Unit name Unit purpose/application ICTWEB425 Apply structured query language to extract and manipulate data This unit describes the skills and knowledge required

More information

Firebird in 2011/2012: Development Review

Firebird in 2011/2012: Development Review Firebird in 2011/2012: Development Review Dmitry Yemanov mailto:dimitr@firebirdsql.org Firebird Project http://www.firebirdsql.org/ Packages Released in 2011 Firebird 2.1.4 March 2011 96 bugs fixed 4 improvements,

More information

Relational Query Optimization. Highlights of System R Optimizer

Relational Query Optimization. Highlights of System R Optimizer Relational Query Optimization Chapter 15 Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 1 Highlights of System R Optimizer v Impact: Most widely used currently; works well for < 10 joins.

More information

Outline. Database Management and Tuning. Outline. Join Strategies Running Example. Index Tuning. Johann Gamper. Unit 6 April 12, 2012

Outline. Database Management and Tuning. Outline. Join Strategies Running Example. Index Tuning. Johann Gamper. Unit 6 April 12, 2012 Outline Database Management and Tuning Johann Gamper Free University of Bozen-Bolzano Faculty of Computer Science IDSE Unit 6 April 12, 2012 1 Acknowledgements: The slides are provided by Nikolaus Augsten

More information

Sql Server Syllabus. Overview

Sql Server Syllabus. Overview Sql Server Syllabus Overview This SQL Server training teaches developers all the Transact-SQL skills they need to create database objects like Tables, Views, Stored procedures & Functions and triggers

More information

SQL: Data Querying. B0B36DBS, BD6B36DBS: Database Systems. h p://www.ksi.m.cuni.cz/~svoboda/courses/172-b0b36dbs/ Lecture 4

SQL: Data Querying. B0B36DBS, BD6B36DBS: Database Systems. h p://www.ksi.m.cuni.cz/~svoboda/courses/172-b0b36dbs/ Lecture 4 B0B36DBS, BD6B36DBS: Database Systems h p://www.ksi.m.cuni.cz/~svoboda/courses/172-b0b36dbs/ Lecture 4 SQL: Data Querying Mar n Svoboda mar n.svoboda@fel.cvut.cz 20. 3. 2018 Czech Technical University

More information

Querying Data with Transact-SQL

Querying Data with Transact-SQL Course Outline 20761- Querying Data with Transact-SQL Duration: 5 days (30 hours) Target Audience: This course is the intended for Database Administrators, Database Developers, and Business Intelligence

More information

Plan for today. Query Processing/Optimization. Parsing. A query s trip through the DBMS. Validation. Logical plan

Plan for today. Query Processing/Optimization. Parsing. A query s trip through the DBMS. Validation. Logical plan Plan for today Query Processing/Optimization CPS 216 Advanced Database Systems Overview of query processing Query execution Query plan enumeration Query rewrite heuristics Query rewrite in DB2 2 A query

More information

Parallelism Strategies In The DB2 Optimizer

Parallelism Strategies In The DB2 Optimizer Session: A05 Parallelism Strategies In The DB2 Optimizer Calisto Zuzarte IBM Toronto Lab May 20, 2008 09:15 a.m. 10:15 a.m. Platform: DB2 on Linux, Unix and Windows The Database Partitioned Feature (DPF)

More information

DB2 for LUW Advanced Statistics with Statistical Views. John Hornibrook Manager DB2 for LUW Query Optimization Development

DB2 for LUW Advanced Statistics with Statistical Views. John Hornibrook Manager DB2 for LUW Query Optimization Development DB2 for LUW Advanced Statistics with Statistical Views John Hornibrook Manager DB2 for LUW Query Optimization Development 1 Session Information Presentation Category: DB2 for LUW 2 DB2 for LUW Advanced

More information

Slicing and Dicing Data in CF and SQL: Part 1

Slicing and Dicing Data in CF and SQL: Part 1 Slicing and Dicing Data in CF and SQL: Part 1 Charlie Arehart Founder/CTO Systemanage carehart@systemanage.com SysteManage: Agenda Slicing and Dicing Data in Many Ways Handling Distinct Column Values Manipulating

More information

Overview of Query Processing

Overview of Query Processing ICS 321 Fall 2013 Overview of Query Processing Asst. Prof. Lipyeow Lim Information & Computer Science Department University of Hawaii at Manoa 11/20/2013 Lipyeow Lim -- University of Hawaii at Manoa 1

More information

Course 20461C: Querying Microsoft SQL Server

Course 20461C: Querying Microsoft SQL Server Course 20461C: Querying Microsoft SQL Server About this course: This course is the foundation for all SQL Server related disciplines; namely, Database Administration, Database development and business

More information

Optimizer Challenges in a Multi-Tenant World

Optimizer Challenges in a Multi-Tenant World Optimizer Challenges in a Multi-Tenant World Pat Selinger pselinger@salesforce.come Classic Query Optimizer Concepts & Assumptions Relational Model Cost = X * CPU + Y * I/O Cardinality Selectivity Clustering

More information

Reminders. Query Optimizer Overview. The Three Parts of an Optimizer. Dynamic Programming. Search Algorithm. CSE 444: Database Internals

Reminders. Query Optimizer Overview. The Three Parts of an Optimizer. Dynamic Programming. Search Algorithm. CSE 444: Database Internals Reminders CSE 444: Database Internals Lab 2 is due on Wednesday HW 5 is due on Friday Lecture 11 Query Optimization (part 2) CSE 444 - Winter 2017 1 CSE 444 - Winter 2017 2 Query Optimizer Overview Input:

More information

A subquery is a nested query inserted inside a large query Generally occurs with select, from, where Also known as inner query or inner select,

A subquery is a nested query inserted inside a large query Generally occurs with select, from, where Also known as inner query or inner select, Sub queries A subquery is a nested query inserted inside a large query Generally occurs with select, from, where Also known as inner query or inner select, Result of the inner query is passed to the main

More information

DB2 UDB: Application Programming

DB2 UDB: Application Programming A ABS or ABSVAL... 4:19 Access Path - Determining... 10:8 Access Strategies... 9:3 Additional Facts About Data Types... 5:18 Aliases... 1:13 ALL, ANY, SOME Operator... 3:21 AND... 3:12 Arithmetic Expressions...

More information

Oracle Database 10g: Introduction to SQL

Oracle Database 10g: Introduction to SQL ORACLE UNIVERSITY CONTACT US: 00 9714 390 9000 Oracle Database 10g: Introduction to SQL Duration: 5 Days What you will learn This course offers students an introduction to Oracle Database 10g database

More information

Database Systems: Design, Implementation, and Management Tenth Edition. Chapter 8 Advanced SQL

Database Systems: Design, Implementation, and Management Tenth Edition. Chapter 8 Advanced SQL Database Systems: Design, Implementation, and Management Tenth Edition Chapter 8 Advanced SQL Objectives In this chapter, you will learn: How to use the advanced SQL JOIN operator syntax About the different

More information

Query Execution [15]

Query Execution [15] CSC 661, Principles of Database Systems Query Execution [15] Dr. Kalpakis http://www.csee.umbc.edu/~kalpakis/courses/661 Query processing involves Query processing compilation parsing to construct parse

More information

RELATIONAL DATA MODEL

RELATIONAL DATA MODEL RELATIONAL DATA MODEL EGCO321 DATABASE SYSTEMS KANAT POOLSAWASD DEPARTMENT OF COMPUTER ENGINEERING MAHIDOL UNIVERSITY RELATIONAL DATA STRUCTURE (1) Relation: A relation is a table with columns and rows.

More information

Introduction to Query Processing and Query Optimization Techniques. Copyright 2011 Ramez Elmasri and Shamkant Navathe

Introduction to Query Processing and Query Optimization Techniques. Copyright 2011 Ramez Elmasri and Shamkant Navathe Introduction to Query Processing and Query Optimization Techniques Outline Translating SQL Queries into Relational Algebra Algorithms for External Sorting Algorithms for SELECT and JOIN Operations Algorithms

More information

Learn Well Technocraft

Learn Well Technocraft Note: We are authorized partner and conduct global certifications for Oracle and Microsoft. The syllabus is designed based on global certification standards. This syllabus prepares you for Oracle global

More information