MySQL Query Tuning 101. Sveta Smirnova, Alexander Rubin April, 16, 2015

Size: px
Start display at page:

Download "MySQL Query Tuning 101. Sveta Smirnova, Alexander Rubin April, 16, 2015"

Transcription

1 MySQL Query Tuning 101 Sveta Smirnova, Alexander Rubin April, 16, 2015

2 Agenda 2 Introduction: where to find slow queries Indexes: why and how do they work All about EXPLAIN More tools Where to find more information

3 When you see slow query first 3 You develop an application and find out that some queries are running slow After a while you find some slow queries in the slow query log All such queries are always slow We would not talk about cases when concurrency affects performance

4 Why query can run slow 4 MySQL has to do some job to execute a select query In the worst case scenario it will do a full table scan CREATE INDEX Incorrect index can be used by MySQL

5 Full table scan 5 select * from table select * from table where id=

6 MySQL Indexes 6 When you add index (except for MEMORY) MySQL will use B-Tree Support equality and range operations

7 B-Tree: Equality search 7 select * from table where id = 12 Scan thru the tree and go directly to 1 leaf Stop

8 B-Tree: Range 8 select * from table where id in (6, 12, 18) Scan thru the tree and visit many leafs/nodes

9 How to find out how MySQL uses indexes 9 EXPLAIN Estimates what happens during query execution EXTENDED FORMAT=JSON PARTITIONS INFORMATION SCHEMA.OPTIMIZER TRACE Real data, collected after query was executed Advanced topic

10 Effect of indexes: before 10 mysql> explain select * from t1\g *************************** 1. row ***************************... rows: 12 Extra: NULL mysql> explain select * from t1 where f2=12\g *************************** 1. row ***************************... key: NULL... rows: 12 Same number of examined rows for both queries Extra: Using where

11 Effect of indexes: after 11 mysql> alter table t1 add index(f2); Query OK, 12 rows affected (0.07 sec) Records: 12 Duplicates: 0 Warnings: 0 mysql> explain select * from t1 where f2=12\g *************************** 1. row ***************************... key: f2 key_len: 5 ref: const rows: 1 Extra: NULL 1 row in set (0.00 sec) Much more effective! Only 1 row examined

12 EXPLAIN: overview 12 Number of select Tables, for which information is printed Possible keys Length of the key Number of examined rows Additional information mysql> explain extended select * from t1 join t2 where t1.int_key=1; id select_type table type possible_keys key key_len ref rows filtered Extra SIMPLE t1 ref int_key,ik int_key 5 const NULL 1 SIMPLE t2 index NULL pk 9 NULL Using index; Using join buffer Product of rows here: how many rows in all tables will be accessed Table, for which information is printed (Block Nested Loop) For this example estimated value is 4*6 = 24 2 rows in set, 1 warning (0.00 sec) Select type How data is accessed Key, which was actually used % of filtered rows rows x filtered / 100 number of rows, which will be joined with another table Which columns were compared with the index Note (Code 1003): /* select#1 */ select test. t1. pk AS pk, test. t1. int_key AS int_key, test. t2. pk AS pk, test. t2. int_key AS int_key from test. t1 join test. t2 where ( test. t1. int_key = 1) Actual (optimized) query as executed by MySQL Server

13 EXPLAIN in details 13 mysql> explain extended select * from t1 join t2 where *** id select_type table type *** *** 1 SIMPLE t1 ref *** 1 SIMPLE t2 index *** *** 2 rows in set, 1 warning (0.00 sec) SIMPLE;PRIMARY;UNION;DEPENDENT UNION;UNION RESULT; SUBQUERY;DEPENDENT SUBQUERY;DERIVED;MATERIALIZED system const eq ref ref fulltext ref or null index merge unique subquery index subquery range index ALL

14 EXPLAIN in details: keys 14 Keys, which can be used for resolving the query Actual length of the key (Important for multiple-column keys) mysql> explain extended select * from t1 join t2 where t1.int_key=1; *** *** *** possible_keys key key_len ref *** *** *** *** int_key,ik int_key 5 const *** *** NULL pk 9 NULL *** *** *** 2 rows in set, 1 warning (0.00 sec) Constant Numeric in our case Index used to resolve rows Only one key was actually used Which columns were compared with the index

15 EXPLAIN in details: rows 15 Number of rows accessed % of rows filtered Additional information: how query is resolved Using filesort Using temporary etc. mysql> explain extended select * from t1 join t2 where t1.int_key=1; *** *** rows filtered Extra *** X6 *** NULL = *** Using index; Using join buffer (Block Nested Loop) *** rows in set, 1 warning (0.00 sec) All rows used

16 EXPLAIN type by example: setup 16 MySQL or Percona Server 5.6 Employees test database XML: Fusheng Wang and Carlo Zaniolo SQL: Giuseppe Maxia and Patrick Crews More information Download: Install: cd employees db mysql <employees.sql

17 EXPLAIN type by example: ALL 17 mysql> explain select count(*) from employees where hire_date > \ ********************** 1. row ********************** id: 1 select_type: SIMPLE table: employees type: ALL possible_keys: NULL key: NULL key_len: NULL ref: NULL rows: Extra: Using where 1 row in set (0.00 sec) All rows in the table examined Worst plan ever!

18 EXPLAIN type by example: index 18 mysql> explain select count(*) from titles where title= Senior Engineer \G ********************** 1. row ********************** id: 1 select_type: SIMPLE table: titles type: index possible_keys: NULL key: emp_no key_len: 4 ref: NULL rows: Extra: Using where; Using index 1 row in set (0.11 sec) No row in the table was accessed to resolve the query! Only index used Still all records in the index were scanned

19 EXPLAIN type by example: range 19 We need to add index to table employees first mysql> alter table employees \ -> add index(hire_date); Query OK, 0 rows affected (3.48 sec) Records: 0 Duplicates: 0 Warnings: 0

20 EXPLAIN type by example: range 20 mysql> explain select count(*) from employees where hire_date > \ ********************** 1. row ********************** id: 1 Only rows from given range used select_type: SIMPLE table: employees type: range possible_keys: hire_date key: hire_date key_len: 3 Compare with ALL: ref: NULL /68654 = rows: times less rows examined! Extra: Using where; Using index 1 row in set (0.00 sec)

21 Combined indexes 21 Consists of two or more columns Only leftmost part used mysql> alter table City add key comb(countrycode, District, Population), drop key CountryCode;

22 Combined indexes: example 1 22 mysql> explain select * from City where CountryCode = USA \G ********************** 1. row ****************** table: City type: ref possible_keys: comb key: comb key_len: 3 Uses first field from the comb key ref: const rows: 273

23 Combined indexes: example 2 23 mysql> explain select * from City where \ -> District = California and population > 10000\G ********************** 1. row ****************** table: City type: ALL possible_keys: NULL key: NULL key_len: NULL ref: NULL rows: 3868 Can t use combined index: not a leftmost part Does not have the CountryCode in the where clause = can t use comb index

24 Combined indexes: key len 24 Key len = total size (in bytes) of index parts used Index: comb(countrycode, District, Population) Explain: Fields: key: comb CountryCode char(3) key len: 3 District char(20) Population int(11) 3 ->Char(3) ->First field is used

25 Covered indexes 25 Covered index = cover all fields in query select name from City where CountryCode = USA and District = Alaska and population > mysql> alter table City add key cov1(countrycode, District, population, name); 1. Where part 2. Group By/Order (not used now) 3. Select part Uses all fields in the query in particular order

26 EXPLAIN by example: covered indexes 26 mysql> explain select name from City where CountryCode = USA \ -> and District = Alaska and population > 10000\G *************************** 1. row *********** table: City type: range possible_keys: cov1 key: cov1 key_len: 27 ref: NULL rows: 1 Extra: Using where; Using index Covered index is used MySQL will only use index Will not go to the data file

27 EXPLAIN type by example: ref 27 mysql> explain select * from dept_emp where dept_no = d005 \G ************************ 1. row ************************ id: 1 select_type: SIMPLE table: dept_emp type: ref possible_keys: dept_no key: dept_no key_len: 4 ref: const rows: Extra: Using where 1 row in set (0.00 sec)

28 EXPLAIN type by example: eq ref 28 mysql> explain select * from dept_manager join employees using(emp_no) limit 10\G ************************ 1. row ************************ id: 1 select_type: SIMPLE table: dept_manager type: ALL possible_keys: PRIMARY,emp_no key: NULL key_len: NULL ref: NULL rows: 24 Extra:

29 EXPLAIN type by example: eq ref 29 ************************ 2. row ************************ id: 1 select_type: SIMPLE table: employees type: eq_ref possible_keys: PRIMARY key: PRIMARY key_len: 4 ref: employees.dept_manager.emp_no rows: 1 Extra: 2 rows in set (0.00 sec)

30 EXPLAIN type by example: const 30 mysql> explain select * from departments where dept_no= d005 \G ************************ 1. row ************************ id: 1 select_type: SIMPLE table: departments type: const possible_keys: PRIMARY key: PRIMARY key_len: 4 ref: const rows: 1 Extra: 1 row in set (0.00 sec)

31 EXPLAIN limitations and extensions 31 Limitations It shows estimates only Extensions EXTENDED PARTITIONS FORMAT=JSON

32 EXPLAIN PARTITIONS 32 mysql> explain partitions select count(*) \ -> from employees_part where hire_date > \G ************************ 1. row ************************ id: 1 select_type: SIMPLE table: employees_part partitions: p1,p2 type: index possible_keys: NULL key: PRIMARY key_len: 7 ref: NULL rows: Extra: Using where; Using index

33 EXPLAIN FORMAT=JSON 33 Gives more information Real execution path of the query Pushed conditions Temporary table and index creation are more precise Reflects execution order of group by and order by operations Displays table materializations

34 EXPLAIN FORMAT=JSON 34 mysql> explain format=json insert into salaries(emp_no, from_date) select emp_no, min(from_date) from titles group by emp_no\g *********************** 1. row *********************** EXPLAIN: { "query_block": { "select_id": 1, "grouping_operation": { "using_filesort": false, "table": { "table_name": "titles",

35 EXPLAIN for DML: not only SELECT 35 mysql> explain insert into salaries(emp_no, from_date) \ -> select emp_no, min(from_date) from titles group by emp_no\g ********************** 1. row ********************** id: 1 select_type: SIMPLE table: titles type: index possible_keys: NULL key: emp_no

36 EXPLAIN for DML: not only SELECT 36 mysql> explain insert into salaries(emp_no, from_date) select emp_no, min(from_date) from titles group by emp_no\g... key_len: 4 ref: NULL rows: Extra: Using index 1 row in set, 2 warnings (0.00 sec) Warning (Code 1364): Field salary doesn t have a default value Warning (Code 1364): Field to_date doesn t have a default value

37 Other tools 37 Status variables Handler % Performance schema events stages % events statements % INFORMATION SCHEMA.OPTIMIZER TRACE

38 More to learn 38 MySQL User Reference Manual MySQL Troubleshooting book High Performance MySQL book MySQL Performance Blog Planet MySQL Troubleshooting Performance Companion slides

39 Thank you! 39

40 Questions? 40?

Troubleshooting Slow Queries. Sveta Smirnova Principal Support Engineer April, 28, 2016

Troubleshooting Slow Queries. Sveta Smirnova Principal Support Engineer April, 28, 2016 Troubleshooting Slow Queries Sveta Smirnova Principal Support Engineer April, 28, 2016 Table of Contents Before we start What affects query execution EXPLAIN: how to find out how optimizer works Data matters:

More information

Advanced MySQL Query Tuning

Advanced MySQL Query Tuning Advanced MySQL Query Tuning Alexander Rubin July 21, 2013 About Me My name is Alexander Rubin Working with MySQL for over 10 years Started at MySQL AB, then Sun Microsystems, then Oracle (MySQL Consulting)

More information

Tired of MySQL Making You Wait? Alexander Rubin, Principal Consultant, Percona Janis Griffin, Database Evangelist, SolarWinds

Tired of MySQL Making You Wait? Alexander Rubin, Principal Consultant, Percona Janis Griffin, Database Evangelist, SolarWinds Tired of MySQL Making You Wait? Alexander Rubin, Principal Consultant, Percona Janis Griffin, Database Evangelist, SolarWinds Who Am I? Senior DBA / Performance Evangelist for Solarwinds Janis.Griffin@solarwinds.com

More information

Advanced MySQL Query Tuning

Advanced MySQL Query Tuning Advanced MySQL Query Tuning Alexander Rubin August 6, 2014 About Me My name is Alexander Rubin Working with MySQL for over 10 years Started at MySQL AB, then Sun Microsystems, then Oracle (MySQL Consulting)

More information

MySQL Performance Optimization

MySQL Performance Optimization P R A C T I C A L MySQL Performance Optimization A hands-on, business-case-driven guide to understanding MySQL query parameter tuning and database performance optimization. With the increasing importance

More information

Optimizing Queries with EXPLAIN

Optimizing Queries with EXPLAIN Optimizing Queries with EXPLAIN Sheeri Cabral Senior Database Administrator Twitter: @sheeri What is EXPLAIN? SQL Extension Just put it at the beginning of your statement Can also use DESC or DESCRIBE

More information

Query Optimization Percona, Inc. 1 / 74

Query Optimization Percona, Inc. 1 / 74 Query Optimization http://www.percona.com/training/ 2011-2017 Percona, Inc. 1 / 74 Table of Contents 1. Query Planning 3. Composite Indexes 2. Explaining the EXPLAIN 4. Kitchen Sink 2011-2017 Percona,

More information

Indexes - What You Need to Know

Indexes - What You Need to Know Indexes - What You Need to Know http://www.percona.com/training/ 2011-2017 Percona, Inc. 1 / 53 Indexes - Need to Know QUERY PLANNING 2011-2017 Percona, Inc. 2 / 53 About This Chapter The number one goal

More information

1Z MySQL 5 Database Administrator Certified Professional Exam, Part II Exam.

1Z MySQL 5 Database Administrator Certified Professional Exam, Part II Exam. Oracle 1Z0-874 MySQL 5 Database Administrator Certified Professional Exam, Part II Exam TYPE: DEMO http://www.examskey.com/1z0-874.html Examskey Oracle 1Z0-874 exam demo product is here for you to test

More information

Covering indexes. Stéphane Combaudon - SQLI

Covering indexes. Stéphane Combaudon - SQLI Covering indexes Stéphane Combaudon - SQLI Indexing basics Data structure intended to speed up SELECTs Similar to an index in a book Overhead for every write Usually negligeable / speed up for SELECT Possibility

More information

PostgreSQL to MySQL A DBA's Perspective. Patrick

PostgreSQL to MySQL A DBA's Perspective. Patrick PostgreSQL to MySQL A DBA's Perspective Patrick King @mr_mustash Yelp s Mission Connecting people with great local businesses. My Database Experience Started using Postgres 7 years ago Postgres 8.4 (released

More information

OKC MySQL Users Group

OKC MySQL Users Group OKC MySQL Users Group OKC MySQL Discuss topics about MySQL and related open source RDBMS Discuss complementary topics (big data, NoSQL, etc) Help to grow the local ecosystem through meetups and events

More information

When and How to Take Advantage of New Optimizer Features in MySQL 5.6. Øystein Grøvlen Senior Principal Software Engineer, MySQL Oracle

When and How to Take Advantage of New Optimizer Features in MySQL 5.6. Øystein Grøvlen Senior Principal Software Engineer, MySQL Oracle When and How to Take Advantage of New Optimizer Features in MySQL 5.6 Øystein Grøvlen Senior Principal Software Engineer, MySQL Oracle Program Agenda Improvements for disk-bound queries Subquery improvements

More information

Practical MySQL indexing guidelines

Practical MySQL indexing guidelines Practical MySQL indexing guidelines Percona Live October 24th-25th, 2011 London, UK Stéphane Combaudon stephane.combaudon@dailymotion.com Agenda Introduction Bad indexes & performance drops Guidelines

More information

Advanced query optimization techniques on large queries. Peter Boros Percona Webinar

Advanced query optimization techniques on large queries. Peter Boros Percona Webinar Advanced query optimization techniques on large queries Peter Boros Percona Webinar Agenda Showing the title slide Going through this agenda Prerequisites Case study #1 Case study #2 Case study #3 Case

More information

Introduction to Troubleshooting Performance What Affects Query Execution? Sveta Smirnova Principal Support Engineer April, 7, 2016

Introduction to Troubleshooting Performance What Affects Query Execution? Sveta Smirnova Principal Support Engineer April, 7, 2016 Introduction to Troubleshooting Performance What Affects Query Execution? Sveta Smirnova Principal Support Engineer April, 7, 2016 Terms of conditions The query Controlling optimizer Concurrency Hardware

More information

The MariaDB/MySQL Query Executor In-depth. Presented by: Timour Katchaounov Optimizer team: Igor Babaev, Sergey Petrunia, Timour Katchaounov

The MariaDB/MySQL Query Executor In-depth. Presented by: Timour Katchaounov Optimizer team: Igor Babaev, Sergey Petrunia, Timour Katchaounov The MariaDB/MySQL Query Executor In-depth Presented by: Timour Katchaounov Optimizer team: Igor Babaev, Sergey Petrunia, Timour Katchaounov Outline What's IN Query engine architecture Execution model Representation

More information

CS 464/564 Introduction to Database Management System Instructor: Abdullah Mueen

CS 464/564 Introduction to Database Management System Instructor: Abdullah Mueen CS 464/564 Introduction to Database Management System Instructor: Abdullah Mueen LECTURE 10: INTRODUCTION TO SQL FULL RELATIONAL OPERATIONS MODIFICATION LANGUAGE Union, Intersection, Differences (select

More information

Optimizer Standof. MySQL 5.6 vs MariaDB 5.5. Peter Zaitsev, Ovais Tariq Percona Inc April 18, 2012

Optimizer Standof. MySQL 5.6 vs MariaDB 5.5. Peter Zaitsev, Ovais Tariq Percona Inc April 18, 2012 Optimizer Standof MySQL 5.6 vs MariaDB 5.5 Peter Zaitsev, Ovais Tariq Percona Inc April 18, 2012 Thank you Ovais Tariq Ovais Did a lot of heavy lifing for this presentation He could not come to talk together

More information

Oracle 1Z MySQL 5.6 Database Administrator. Download Full Version :

Oracle 1Z MySQL 5.6 Database Administrator. Download Full Version : Oracle 1Z0-883 MySQL 5.6 Database Administrator Download Full Version : http://killexams.com/pass4sure/exam-detail/1z0-883 D. The mysqld binary was not compiled with SSL support. E. The server s SSL certificate

More information

CS 464/564 Introduction to Database Management System Instructor: Abdullah Mueen

CS 464/564 Introduction to Database Management System Instructor: Abdullah Mueen CS 464/564 Introduction to Database Management System Instructor: Abdullah Mueen LECTURE 9: INTRODUCTION TO SQL SELECT-FROM-WHERE STATEMENTS SUBQUERIES Set-up the database 1. Log in to your machine using

More information

Explaining the MySQL EXPLAIN

Explaining the MySQL EXPLAIN Explaining the MySQL EXPLAIN Ronald Bradford http://ronaldbradford.com OTN South America Tour July 2011 Agenda EXPLAIN syntax options How to read QEP QEP examples MySQL optimizer limitations PURPOSE EXPLAIN

More information

Lecture 19 Query Processing Part 1

Lecture 19 Query Processing Part 1 CMSC 461, Database Management Systems Spring 2018 Lecture 19 Query Processing Part 1 These slides are based on Database System Concepts 6 th edition book (whereas some quotes and figures are used from

More information

Writing High Performance SQL Statements. Tim Sharp July 14, 2014

Writing High Performance SQL Statements. Tim Sharp July 14, 2014 Writing High Performance SQL Statements Tim Sharp July 14, 2014 Introduction Tim Sharp Technical Account Manager Percona since 2013 16 years working with Databases Optimum SQL Performance Schema Indices

More information

MySQL Indexing. Best Practices for MySQL 5.6. Peter Zaitsev CEO, Percona MySQL Connect Sep 22, 2013 San Francisco,CA

MySQL Indexing. Best Practices for MySQL 5.6. Peter Zaitsev CEO, Percona MySQL Connect Sep 22, 2013 San Francisco,CA MySQL Indexing Best Practices for MySQL 5.6 Peter Zaitsev CEO, Percona MySQL Connect Sep 22, 2013 San Francisco,CA For those who Does not Know Us Percona Helping Businesses to be Successful with MySQL

More information

MySQL Indexing. Best Practices. Peter Zaitsev, CEO Percona Inc August 15, 2012

MySQL Indexing. Best Practices. Peter Zaitsev, CEO Percona Inc August 15, 2012 MySQL Indexing Best Practices Peter Zaitsev, CEO Percona Inc August 15, 2012 You ve Made a Great Choice! Understanding indexing is crucial both for Developers and DBAs Poor index choices are responsible

More information

Part 1: IoT demo Part 2: MySQL, JSON and Flexible storage

Part 1: IoT demo Part 2: MySQL, JSON and Flexible storage Part 1: IoT demo Part 2: MySQL, JSON and Flexible storage $ node particle_mysql_all.js Starting... INSERT INTO cloud_data_json (name, data) values ('particle', '{\"data\":\"null\",\"ttl\":60,\"published_at\":\"2017-09-28t19:40:49.869z\",\"coreid\":\"1f0039000947343337373738

More information

DATABASE PERFORMANCE AND INDEXES. CS121: Relational Databases Fall 2017 Lecture 11

DATABASE PERFORMANCE AND INDEXES. CS121: Relational Databases Fall 2017 Lecture 11 DATABASE PERFORMANCE AND INDEXES CS121: Relational Databases Fall 2017 Lecture 11 Database Performance 2 Many situations where query performance needs to be improved e.g. as data size grows, query performance

More information

<Insert Picture Here> Boosting performance with MySQL partitions

<Insert Picture Here> Boosting performance with MySQL partitions Boosting performance with MySQL partitions Giuseppe Maxia MySQL Community Team Lead at Oracle 1 about me -Giuseppe Maxia a.k.a. The Data Charmer MySQL Community Team Lead Long time

More information

SQL QUERY EVALUATION. CS121: Relational Databases Fall 2017 Lecture 12

SQL QUERY EVALUATION. CS121: Relational Databases Fall 2017 Lecture 12 SQL QUERY EVALUATION CS121: Relational Databases Fall 2017 Lecture 12 Query Evaluation 2 Last time: Began looking at database implementation details How data is stored and accessed by the database Using

More information

Introduction to troubleshooting Basic techniques. Sveta Smirnova Principal Support Engineer March, 10, 2016

Introduction to troubleshooting Basic techniques. Sveta Smirnova Principal Support Engineer March, 10, 2016 Introduction to troubleshooting Basic techniques Sveta Smirnova Principal Support Engineer March, 10, 2016 Table of Contents Introduction How to find problematic query Solving issues Syntax errors Logic

More information

Tools and Techniques for Index Design. Bill Karwin, Percona Inc.

Tools and Techniques for Index Design. Bill Karwin, Percona Inc. Tools and Techniques for Index Design Bill Karwin, Percona Inc. It s About Performance What s the most frequent recommendation in database performance audits? What s the easiest way to speed up SQL queries,

More information

Objectives. After completing this lesson, you should be able to do the following:

Objectives. After completing this lesson, you should be able to do the following: Objectives After completing this lesson, you should be able to do the following: Describe the types of problems that subqueries can solve Define subqueries List the types of subqueries Write single-row

More information

State of MariaDB. Igor Babaev Notice: MySQL is a registered trademark of Sun Microsystems, Inc.

State of MariaDB. Igor Babaev Notice: MySQL is a registered trademark of Sun Microsystems, Inc. State of MariaDB Igor Babaev igor@askmonty.org New features in MariaDB 5.2 New engines: OQGRAPH, SphinxSE Virtual columns Extended User Statistics Segmented MyISAM key cache Pluggable Authentication Storage-engine-specific

More information

Data about data is database Select correct option: True False Partially True None of the Above

Data about data is database Select correct option: True False Partially True None of the Above Within a table, each primary key value. is a minimal super key is always the first field in each table must be numeric must be unique Foreign Key is A field in a table that matches a key field in another

More information

The Blackhole and Federated Storage Engines: The Coolest Kids on the Block

The Blackhole and Federated Storage Engines: The Coolest Kids on the Block The Blackhole and Federated Storage Engines: The Coolest Kids on the Block Kai Voigt, kai@mysql.com Senior Instructor, MySQL AB Giuseppe Maxia, giuseppe@mysql.com QA Developer, MySQL AB Kai Voigt Mister

More information

[Some of] New Query Optimizer features in MariaDB Sergei Petrunia MariaDB Shenzhen Meetup November 2017

[Some of] New Query Optimizer features in MariaDB Sergei Petrunia MariaDB Shenzhen Meetup November 2017 [Some of] New Query Optimizer features in MariaDB 10.3 Sergei Petrunia MariaDB Shenzhen Meetup November 2017 2 Plan MariaDB 10.2: Condition pushdown MariaDB 10.3: Condition pushdown

More information

CSED421 Database Systems Lab. Index

CSED421 Database Systems Lab. Index CSED421 Database Systems Lab Index Index of Index What is an index? When to Create an Index or Not? Index Syntax UNIQUE Index / Indexing Prefixes / Multiple-column index Confirming indexes Index types

More information

Introduction to MySQL NDB Cluster. Yves Trudeau Ph. D. Percona Live DC/January 2012

Introduction to MySQL NDB Cluster. Yves Trudeau Ph. D. Percona Live DC/January 2012 Introduction to MySQL NDB Cluster Yves Trudeau Ph. D. Percona Live DC/January 2012 Agenda What is NDB Cluster? How MySQL uses NDB Cluster Good use cases Bad use cases Example of tuning What is NDB cluster?

More information

Query Optimization, part 2: query plans in practice

Query Optimization, part 2: query plans in practice Query Optimization, part 2: query plans in practice CS634 Lecture 13 Slides by E. O Neil based on Database Management Systems 3 rd ed, Ramakrishnan and Gehrke Working with the Oracle query optimizer First

More information

Lab # 3 Hands-On. DML Basic SQL Statements Institute of Computer Science, University of Tartu, Estonia

Lab # 3 Hands-On. DML Basic SQL Statements Institute of Computer Science, University of Tartu, Estonia Lab # 3 Hands-On DML Basic SQL Statements Institute of Computer Science, University of Tartu, Estonia DML: Data manipulation language statements access and manipulate data in existing schema objects. These

More information

Meet the Sergei Golubchik MariaDB Corporation

Meet the Sergei Golubchik MariaDB Corporation Meet the 10.2 Sergei Golubchik MariaDB Corporation k 10.2 Facts About a year in active development Currently at 10.2.2 beta Plans Gamma soon GA by the end of the year 10.2 Analytical queries Removing historical

More information

Effective Testing for Live Applications. March, 29, 2018 Sveta Smirnova

Effective Testing for Live Applications. March, 29, 2018 Sveta Smirnova Effective Testing for Live Applications March, 29, 2018 Sveta Smirnova Table of Contents Sometimes You Have to Test on Production Wrong Data SELECT Returns Nonsense Wrong Data in the Database Performance

More information

Query Optimizer MySQL vs. PostgreSQL

Query Optimizer MySQL vs. PostgreSQL Percona Live, Santa Clara (USA), 24 April 2018 Christian Antognini @ChrisAntognini antognini.ch/blog BASEL BERN BRUGG DÜSSELDORF FRANKFURT A.M. FREIBURG I.BR. GENEVA HAMBURG COPENHAGEN LAUSANNE MUNICH

More information

CS 327E Lecture 2. Shirley Cohen. January 27, 2016

CS 327E Lecture 2. Shirley Cohen. January 27, 2016 CS 327E Lecture 2 Shirley Cohen January 27, 2016 Agenda Announcements Homework for today Reading Quiz Concept Questions Homework for next time Announcements Lecture slides and notes will be posted on the

More information

Copyright 2014, Oracle and/or its affiliates. All rights reserved.

Copyright 2014, Oracle and/or its affiliates. All rights reserved. Basic MySQL Troubleshooting for Oracle DBAs Sveta Smirnova Senior Principal Technical Support Engineer MySQL Support September 29, 2014 Safe Harbor Statement The following is intended to outline our general

More information

Downloaded from

Downloaded from Lesson 16: Table and Integrity Constraints Integrity Constraints are the rules that a database must follow at all times. Various Integrity constraints are as follows:- 1. Not Null: It ensures that we cannot

More information

Creating and Managing Tables Schedule: Timing Topic

Creating and Managing Tables Schedule: Timing Topic 9 Creating and Managing Tables Schedule: Timing Topic 30 minutes Lecture 20 minutes Practice 50 minutes Total Objectives After completing this lesson, you should be able to do the following: Describe the

More information

Target Practice. A Workshop in Tuning MySQL Queries OSCON Jay Pipes Community Relations Manager, North America MySQL, Inc.

Target Practice. A Workshop in Tuning MySQL Queries OSCON Jay Pipes Community Relations Manager, North America MySQL, Inc. Target Practice A Workshop in Tuning MySQL Queries OSCON 2007 Jay Pipes Community Relations Manager, North America MySQL, Inc. Setup Download materials and MySQL Community Server Download workshop materials

More information

Insertions, Deletions, and Updates

Insertions, Deletions, and Updates Insertions, Deletions, and Updates Lecture 5 Robb T. Koether Hampden-Sydney College Wed, Jan 24, 2018 Robb T. Koether (Hampden-Sydney College) Insertions, Deletions, and Updates Wed, Jan 24, 2018 1 / 17

More information

Partitioning. Sheeri K. Cabral Database Administrator The Pythian Group, January 12, 2009

Partitioning. Sheeri K. Cabral Database Administrator The Pythian Group,  January 12, 2009 Partitioning Sheeri K. Cabral Database Administrator The Pythian Group, www.pythian.com cabral@pythian.com January 12, 2009 Partitioning Why What How How to Partition CREATE TABLE tblname ( fld FLDTYPE...

More information

How to Use JSON in MySQL Wrong

How to Use JSON in MySQL Wrong How to Use JSON in MySQL Wrong Bill Karwin, Square Inc. October, 2018 1 Me Database Developer at Square Inc. MySQL Quality Contributor Author of SQL Antipatterns: Avoiding the Pitfalls of Database Programming

More information

MySQL 8.0 What s New in the Optimizer

MySQL 8.0 What s New in the Optimizer MySQL 8.0 What s New in the Optimizer Manyi Lu Director MySQL Optimizer & GIS Team, Oracle October 2016 Copyright Copyright 2 015, 2016,Oracle Oracle and/or and/or its its affiliates. affiliates. All All

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

<Insert Picture Here> Upcoming Changes in MySQL 5.7 Morgan Tocker, MySQL Community Manager

<Insert Picture Here> Upcoming Changes in MySQL 5.7 Morgan Tocker, MySQL Community Manager Upcoming Changes in MySQL 5.7 Morgan Tocker, MySQL Community Manager http://www.tocker.ca/ Safe Harbor Statement The following is intended to outline our general product direction.

More information

Databases IIB: DBMS-Implementation Exercise Sheet 13

Databases IIB: DBMS-Implementation Exercise Sheet 13 Prof. Dr. Stefan Brass January 27, 2017 Institut für Informatik MLU Halle-Wittenberg Databases IIB: DBMS-Implementation Exercise Sheet 13 As requested by the students, the repetition questions a) will

More information

Data Modelling and Databases. Exercise Session 7: Integrity Constraints

Data Modelling and Databases. Exercise Session 7: Integrity Constraints Data Modelling and Databases Exercise Session 7: Integrity Constraints 1 Database Design Textual Description Complete Design ER Diagram Relational Schema Conceptual Modeling Logical Modeling Physical Modeling

More information

Assignment 6: SQL III Solution

Assignment 6: SQL III Solution Data Modelling and Databases Exercise dates: April 12/April 13, 2018 Ce Zhang, Gustavo Alonso Last update: April 16, 2018 Spring Semester 2018 Head TA: Ingo Müller Assignment 6: SQL III Solution This assignment

More information

MySQL Query Optimization. Originally: Query Optimization from 0 to 10 by Jaime Crespo

MySQL Query Optimization. Originally: Query Optimization from 0 to 10 by Jaime Crespo MySQL Query Optimization Originally: Query Optimization from 0 to 10 by Jaime Crespo Agenda 1. Introduction 7. Query Profiling 2. Access Types and Basic Indexing Techniques 8. General Optimizer Improvements

More information

Query Optimizer MySQL vs. PostgreSQL

Query Optimizer MySQL vs. PostgreSQL Percona Live, Frankfurt (DE), 7 November 2018 Christian Antognini @ChrisAntognini antognini.ch/blog BASEL BERN BRUGG DÜSSELDORF FRANKFURT A.M. FREIBURG I.BR. GENEVA HAMBURG COPENHAGEN LAUSANNE MUNICH STUTTGART

More information

SQL Structured Query Language Introduction

SQL Structured Query Language Introduction SQL Structured Query Language Introduction Rifat Shahriyar Dept of CSE, BUET Tables In relational database systems data are represented using tables (relations). A query issued against the database also

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

Tables From Existing Tables

Tables From Existing Tables Creating Tables From Existing Tables After completing this module, you will be able to: Create a clone of an existing table. Create a new table from many tables using a SQL SELECT. Define your own table

More information

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

<Insert Picture Here> MySQL 5.1 and 5.5 partitions

<Insert Picture Here> MySQL 5.1 and 5.5 partitions MySQL 5.1 and 5.5 partitions Giuseppe Maxia MySQL Community Team Lead MySQL 5.1 and 5.5 Partitions Giuseppe Maxia MySQL Community Team Lead twitter: @datacharmer about me -Giuseppe

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

Practical Performance Tuning using Digested SQL Logs. Bob Burgess Salesforce Marketing Cloud

Practical Performance Tuning using Digested SQL Logs. Bob Burgess Salesforce Marketing Cloud Practical Performance Tuning using Digested SQL Logs Bob Burgess Salesforce Marketing Cloud Who?! Database Architect! Salesforce Marketing Cloud (Radian6 & Buddy Media stack) Why?! I can t be the only

More information

Assignment 6: SQL III

Assignment 6: SQL III Data Modelling and Databases Exercise dates: April 12/April 13, 2018 Ce Zhang, Gustavo Alonso Last update: April 16, 2018 Spring Semester 2018 Head TA: Ingo Müller Assignment 6: SQL III This assignment

More information

Oracle DB-Tuning Essentials

Oracle DB-Tuning Essentials Infrastructure at your Service. Oracle DB-Tuning Essentials Agenda 1. The DB server and the tuning environment 2. Objective, Tuning versus Troubleshooting, Cost Based Optimizer 3. Object statistics 4.

More information

IBM A Assessment: DB2 9 Fundamentals-Assessment. Download Full Version :

IBM A Assessment: DB2 9 Fundamentals-Assessment. Download Full Version : IBM A2090-730 Assessment: DB2 9 Fundamentals-Assessment Download Full Version : http://killexams.com/pass4sure/exam-detail/a2090-730 C. 2 D. 3 Answer: C QUESTION: 294 In which of the following situations

More information

Copyright 2017, Oracle and/or its aff iliates. All rights reserved.

Copyright 2017, Oracle and/or its aff iliates. All rights reserved. Safe Harbor Statement The following is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated into any contract. It is not a commitment

More information

Maximizing SQL reviews with pt-query-digest

Maximizing SQL reviews with pt-query-digest PALOMINODB OPERATIONAL EXCELLENCE FOR DATABASES Maximizing SQL reviews with pt-query-digest Mark Filipi www.palominodb.com What is pt-query-digest Analyzes MySQL queries from slow, general and binary log

More information

Databases - 4. Other relational operations and DDL. How to write RA expressions for dummies

Databases - 4. Other relational operations and DDL. How to write RA expressions for dummies Databases - 4 Other relational operations and DDL How to write RA expressions for dummies Step 1: Identify the relations required and CP them together Step 2: Add required selections to make the CP Step

More information

Full file at

Full file at David Kroenke's Database Processing: Fundamentals, Design and Implementation (10 th Edition) CHAPTER TWO INTRODUCTION TO STRUCTURED QUERY LANGUAGE (SQL) True-False Questions 1. SQL stands for Standard

More information

MySQL 8.0 Optimizer Guide

MySQL 8.0 Optimizer Guide MySQL 8.0 Optimizer Guide Morgan Tocker MySQL Product Manager (Server) Copyright 2016, 2017, Oracle and/or its its affiliates. All All rights rights reserved. Safe Harbor Statement The following is intended

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

Query Evaluation Overview, cont.

Query Evaluation Overview, cont. Query Evaluation Overview, cont. Lecture 9 Feb. 29, 2016 Slides based on Database Management Systems 3 rd ed, Ramakrishnan and Gehrke Architecture of a DBMS Query Compiler Execution Engine Index/File/Record

More information

MySQL Introduction. By Prof. B.A.Khivsara

MySQL Introduction. By Prof. B.A.Khivsara MySQL Introduction By Prof. B.A.Khivsara Note: The material to prepare this presentation has been taken from internet and are generated only for students reference and not for commercial use. Outline Design

More information

MySQL Performance Tuning

MySQL Performance Tuning MySQL Performance Tuning Student Guide D61820GC30 Edition 3.0 January 2017 D89524 Learn more from Oracle University at education.oracle.com Authors Mark Lewin Jeremy Smyth Technical Contributors and Reviewers

More information

Ryan Stephens. Ron Plew Arie D. Jones. Sams Teach Yourself FIFTH EDITION. 800 East 96th Street, Indianapolis, Indiana, 46240

Ryan Stephens. Ron Plew Arie D. Jones. Sams Teach Yourself FIFTH EDITION. 800 East 96th Street, Indianapolis, Indiana, 46240 Ryan Stephens Ron Plew Arie D. Jones Sams Teach Yourself FIFTH EDITION 800 East 96th Street, Indianapolis, Indiana, 46240 Table of Contents Part I: An SQL Concepts Overview HOUR 1: Welcome to the World

More information

SYSTEM CODE COURSE NAME DESCRIPTION SEM

SYSTEM CODE COURSE NAME DESCRIPTION SEM Course: CS691- Database Management System Lab PROGRAMME: COMPUTER SCIENCE & ENGINEERING DEGREE:B. TECH COURSE: Database Management System Lab SEMESTER: VI CREDITS: 2 COURSECODE: CS691 COURSE TYPE: Practical

More information

Query Evaluation Overview, cont.

Query Evaluation Overview, cont. Query Evaluation Overview, cont. Lecture 9 Slides based on Database Management Systems 3 rd ed, Ramakrishnan and Gehrke Architecture of a DBMS Query Compiler Execution Engine Index/File/Record Manager

More information

2) SQL includes a data definition language, a data manipulation language, and SQL/Persistent stored modules. Answer: TRUE Diff: 2 Page Ref: 36

2) SQL includes a data definition language, a data manipulation language, and SQL/Persistent stored modules. Answer: TRUE Diff: 2 Page Ref: 36 Database Processing, 12e (Kroenke/Auer) Chapter 2: Introduction to Structured Query Language (SQL) 1) SQL stands for Standard Query Language. Diff: 1 Page Ref: 32 2) SQL includes a data definition language,

More information

Exact Numeric Data Types

Exact Numeric Data Types SQL Server Notes for FYP SQL data type is an attribute that specifies type of data of any object. Each column, variable and expression has related data type in SQL. You would use these data types while

More information

Databases. Relational Model, Algebra and operations. How do we model and manipulate complex data structures inside a computer system? Until

Databases. Relational Model, Algebra and operations. How do we model and manipulate complex data structures inside a computer system? Until Databases Relational Model, Algebra and operations How do we model and manipulate complex data structures inside a computer system? Until 1970.. Many different views or ways of doing this Could use tree

More information

CS6312 DATABASE MANAGEMENT SYSTEMS LABORATORY L T P C

CS6312 DATABASE MANAGEMENT SYSTEMS LABORATORY L T P C CS6312 DATABASE MANAGEMENT SYSTEMS LABORATORY L T P C 0 0 3 2 LIST OF EXPERIMENTS: 1. Creation of a database and writing SQL queries to retrieve information from the database. 2. Performing Insertion,

More information

Using the Set Operators. Copyright 2006, Oracle. All rights reserved.

Using the Set Operators. Copyright 2006, Oracle. All rights reserved. Using the Set Operators Objectives After completing this lesson, you should be able to do the following: Describe set operators Use a set operator to combine multiple queries into a single query Control

More information

MySQL for Beginners Ed 3

MySQL for Beginners Ed 3 MySQL for Beginners Ed 3 Duration: 4 Days What you will learn The MySQL for Beginners course helps you learn about the world's most popular open source database. Expert Oracle University instructors will

More information

C Examcollection.Premium.Exam.58q

C Examcollection.Premium.Exam.58q C2090-610.Examcollection.Premium.Exam.58q Number: C2090-610 Passing Score: 800 Time Limit: 120 min File Version: 32.2 http://www.gratisexam.com/ Exam Code: C2090-610 Exam Name: DB2 10.1 Fundamentals Visualexams

More information

Oracle 1Z0-882 Exam. Volume: 100 Questions. Question No: 1 Consider the table structure shown by this output: Mysql> desc city:

Oracle 1Z0-882 Exam. Volume: 100 Questions. Question No: 1 Consider the table structure shown by this output: Mysql> desc city: Volume: 100 Questions Question No: 1 Consider the table structure shown by this output: Mysql> desc city: 5 rows in set (0.00 sec) You execute this statement: SELECT -,-, city. * FROM city LIMIT 1 What

More information

MySQL Schema Review 101

MySQL Schema Review 101 MySQL Schema Review 101 How and What you should be looking at... Mike Benshoof - Technical Account Manager, Percona Agenda Introduction Key things to consider and review Tools to isolate issues Common

More information

Data Modelling and Databases Exercise dates: March 22/March 23, 2018 Ce Zhang, Gustavo Alonso Last update: March 26, 2018.

Data Modelling and Databases Exercise dates: March 22/March 23, 2018 Ce Zhang, Gustavo Alonso Last update: March 26, 2018. Data Modelling and Databases Exercise dates: March 22/March 23, 2018 Ce Zhang, Gustavo Alonso Last update: March 26, 2018 Spring Semester 2018 Head TA: Ingo Müller Assignment 4: SQL This assignment will

More information

MySQL Schema Best Practices

MySQL Schema Best Practices MySQL Schema Best Practices 2 Agenda Introduction 3 4 Introduction - Sample Schema Key Considerations 5 Data Types 6 Data Types [root@plive-2017-demo plive_2017]# ls -alh action*.ibd -rw-r-----. 1 mysql

More information

Maintaining Data 3.3.1

Maintaining Data 3.3.1 Maintaining Data Course materials may not be reproduced in whole or in part without the prior written permission of IBM. 4.0.3 3.3.1 Unit Objectives After completing this unit, you should be able to: Create

More information

itexamdump 최고이자최신인 IT 인증시험덤프 일년무료업데이트서비스제공

itexamdump 최고이자최신인 IT 인증시험덤프  일년무료업데이트서비스제공 itexamdump 최고이자최신인 IT 인증시험덤프 http://www.itexamdump.com 일년무료업데이트서비스제공 Exam : 1z1-882 Title : Oracle Certified Professional, MySQL 5.6 Developer Vendor : Oracle Version : DEMO Get Latest & Valid 1z1-882

More information

1z0-882.exam.55q 1z0-882 Oracle Certified Professional, MySQL 5.6 Developer

1z0-882.exam.55q   1z0-882 Oracle Certified Professional, MySQL 5.6 Developer 1z0-882.exam.55q Number: 1z0-882 Passing Score: 800 Time Limit: 120 min 1z0-882 Oracle Certified Professional, MySQL 5.6 Developer Exam A QUESTION 1 Which three are valid identifiers for the user table

More information

Histogram Support in MySQL 8.0

Histogram Support in MySQL 8.0 Histogram Support in MySQL 8.0 Øystein Grøvlen Senior Principal Software Engineer MySQL Optimizer Team, Oracle February 2018 Program Agenda 1 2 3 4 5 Motivating example Quick start guide How are histograms

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

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 4 Professional Program: Data Administration and Management MANAGING DATA(BASES) USING SQL (NON-PROCEDURAL SQL, X401.9) AGENDA

More information

QMF: Query Management Facility

QMF: Query Management Facility A A Report - Figure 7... 1:26 ADD Sessions - Ending a Table Editor... 5:5 Adding Rows to a Table... 5:1 Adding Comments to an SQL Query... 3:5 ALIGN... 4:16 Arithmetic in Queries... 3:17 Available Tables

More information