SlideShare une entreprise Scribd logo
1  sur  67
Télécharger pour lire hors ligne
MariaDB Improvements
in the Latest Versions
September 14-16, 2020
Sveta Smirnova
• MySQL Support Engineer
• Author of
• MySQL Troubleshooting
• JSON UDF functions
•
FILTER clause for MySQL
• Speaker
• Percona Live, OOW, Fosdem,
DevConf, HighLoad...
Sveta Smirnova
2
•Storage Improvements
•Optimizer and SQL Improvements
Table of Contents
3
1995 Initial Release by MySQL AB
MySQL
4
1995 Initial Release by MySQL AB
2006 Percona Server for MySQL
MySQL
4
1995 Initial Release by MySQL AB
2006 Percona Server for MySQL
2008 Sun owns MySQL
MySQL
4
1995 Initial Release by MySQL AB
2006 Percona Server for MySQL
2008 Sun owns MySQL
2010 Oracle owns Sun
and MySQL
MySQL
4
1995 Initial Release by MySQL AB
2006 Percona Server for MySQL
2008 Sun owns MySQL
2010 Oracle owns Sun
and MySQL
2010 MariaDB
MySQL
4
• Started as fork of MySQL
MariaDB
5
• Started as fork of MySQL
• Independent product
MariaDB
5
• Started as fork of MySQL
• Independent product
• Hundreds of unique features
MariaDB
5
• Started as fork of MySQL
• Independent product
• Hundreds of unique features
• Important improvements are backported
•
from MySQL
MariaDB
5
• Features, ported from MySQL 8.0
This Talk
6
• Features, ported from MySQL 8.0
• Another talk
MySQL 8.0 and Percona Improvements
This Talk
6
• Features, ported from MySQL 8.0
• Another talk
MySQL 8.0 and Percona Improvements
• MariaDB Unique Features
•
Storage Improvements
Alternative storage engines
Others
• Optimizer Improvements
Advanced SQL
Performance and diagnostics
This Talk
6
Storage Improvements
• Storage Engine
S3
8
• Storage Engine
• Data stored on Amazon S3
S3
8
• Storage Engine
• Data stored on Amazon S3
• Any original engine
ALTER TABLE my_table ENGINE=S3;
ALTER TABLE my_table ENGINE=INNODB;
ALTER TABLE my_table ENGINE=S3;
S3
8
• Storage Engine
• Data stored on Amazon S3
• Any original engine
•
Underlying engine is Aria
S3
8
• Storage Engine
• Data stored on Amazon S3
• Any original engine
•
Underlying engine is Aria
•
Read-only tables
S3
8
• Storage Engine
• Data stored on Amazon S3
• Any original engine
•
Underlying engine is Aria
•
Read-only tables
•
Shared and separated storage for replication
S3
8
• Storage Engine
• Data stored on Amazon S3
• Any original engine
•
Underlying engine is Aria
•
Read-only tables
•
Shared and separated storage for replication
•
Own layer to connect to S3: libmarias3
S3
8
• Storage Engine
•
Available since 2017 as a plugin
• Part of 10.5 Community Server release
ColumnStore
9
•
Columnar Storage Engine
• Based on InfiniDB
ColumnStore
9
•
Designed for parallel processing
• SQL interface
• JOINs with SQL engines (InnoDB etc.)
• Easy integration with existent SQL setup
•
All advantages of the column storage
ColumnStore
9
MyRocks
Connect
Mroonga
OQGRAPH
SphinxSE
Spider
Many More Storage Engines
10
• Change history
System-Versioned Tables
11
• PITR on the fly
System-Versioned Tables
11
• PITR on the fly
• Create a versioned table
MariaDB [test]> alter table employees ADD SYSTEM VERSIONING;
Query OK, 300024 rows affected (1.060 sec)
Records: 300024 Duplicates: 0 Warnings: 0
System-Versioned Tables
11
• PITR on the fly
• Check table options
MariaDB [test]> show create table employeesG
*************************** 1. row ***************************
Table: employees
Create Table: CREATE TABLE ‘employees‘ (
‘emp_no‘ int(11) NOT NULL,
‘birth_date‘ date NOT NULL,
‘first_name‘ varchar(14) COLLATE utf8mb4_unicode_ci NOT NULL,
‘last_name‘ varchar(16) COLLATE utf8mb4_unicode_ci NOT NULL,
‘gender‘ enum(’M’,’F’) COLLATE utf8mb4_unicode_ci NOT NULL,
‘hire_date‘ date NOT NULL,
PRIMARY KEY (‘emp_no‘)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci WITH SYSTEM VERSIONING
1 row in set (0.001 sec)
System-Versioned Tables
11
• PITR on the fly
• Perform activities
MariaDB [test]> select count(*) from employees where hire_date < ’1986-01-01’;
+––––––––––+
| count(*) |
+––––––––––+
| 35316 |
+––––––––––+
1 row in set (0.188 sec)
MariaDB [test]> delete from employees where hire_date < ’1986-01-01’;
Query OK, 35316 rows affected (0.837 sec)
System-Versioned Tables
11
• PITR on the fly
• Lost rows
MariaDB [test]> select count(*) from employees where hire_date < ’1986-01-01’;
+––––––––––+
| count(*) |
+––––––––––+
| 0 |
+––––––––––+
1 row in set (0.103 sec)
System-Versioned Tables
11
• PITR on the fly
• Restore deleted rows
MariaDB [test]> insert into employees select * FROM employees
-> FOR SYSTEM_TIME between (now() - interval 1 hour) and now()
-> where hire_date < ’1986-01-01’;
Query OK, 35316 rows affected (0.721 sec)
Records: 35316 Duplicates: 0 Warnings: 0
MariaDB [test]> select count(*) from employees where hire_date < ’1986-01-01’;
+––––––––––+
| count(*) |
+––––––––––+
| 35316 |
+––––––––––+
1 row in set (0.216 sec)
System-Versioned Tables
11
• Change history
• PITR on the fly
• Tunable
Time
Transaction ID
With History, stored separately
Paritioned
With columns, excluded from versioning
With time periods: application history
With both system and application period levels
System-Versioned Tables
11
• Columns, not visible for SELECT *
MariaDB [test]> alter table employees add column address JSON invisible;
Query OK, 0 rows affected (0.005 sec)
Records: 0 Duplicates: 0 Warnings: 0
– Update address for some employees
MariaDB [test]> select * from employees limit 3;
+––––––––+––––––––––––+––––––––––––+–––––––––––+––––––––+––––––––––––+
| emp_no | birth_date | first_name | last_name | gender | hire_date |
+––––––––+––––––––––––+––––––––––––+–––––––––––+––––––––+––––––––––––+
| 10001 | 1953-09-02 | Georgi | Facello | M | 1986-06-26 |
| 10002 | 1964-06-02 | Bezalel | Simmel | F | 1985-11-21 |
| 10003 | 1959-12-03 | Parto | Bamford | M | 1986-08-28 |
+––––––––+––––––––––––+––––––––––––+–––––––––––+––––––––+––––––––––––+
3 rows in set (0.001 sec)
Invisible columns
12
• Columns, not visible for SELECT *
• Accessible for the direct query
MariaDB [test]> select first_name, last_name, json_extract(address, "$.City")
-> from employees where address is not null;
+––––––––––––+–––––––––––+–––––––––––––––––––––––––––––––––+
| first_name | last_name | json_extract(address, "$.City") |
+––––––––––––+–––––––––––+–––––––––––––––––––––––––––––––––+
| Tianruo | Jenevein | "Espoo" |
| Dulce | Kolinko | "Espoo" |
| Masasuke | Gill | "Espoo" |
| Toshimi | Karner | "Espoo" |
| Danco | Yetto | "Espoo" |
+––––––––––––+–––––––––––+–––––––––––––––––––––––––––––––––+
5 rows in set (0.173 sec)
Invisible columns
12
MariaDB [test]> create sequence odds start with 1 increment by 2;
Query OK, 0 rows affected (0.001 sec)
MariaDB [test]> create sequence evens start with 2 increment by 2;
Query OK, 0 rows affected (0.001 sec)
MariaDB [test]> create table numbers(
-> id int not null auto_increment primary key,
-> odd int default next value for odds,
-> even int default next value for evens
-> );
Query OK, 0 rows affected (0.004 sec)
Sequences
13
MariaDB [test]> insert into numbers values (), (), (), (), ();
Query OK, 5 rows affected (0.002 sec)
Records: 5 Duplicates: 0 Warnings: 0
MariaDB [test]> select * from numbers;
+––––+––––––+––––––+
| id | odd | even |
+––––+––––––+––––––+
| 1 | 1 | 2 |
| 2 | 3 | 4 |
| 3 | 5 | 6 |
| 4 | 7 | 8 |
| 5 | 9 | 10 |
+––––+––––––+––––––+
5 rows in set (0.001 sec)
Sequences
13
•
Native IPv6 support
MariaDB [test]> create table inet6_test(ip inet6);
Query OK, 0 rows affected (0.001 sec)
MariaDB [test]> insert into inet6_test values(’fe80::e43b:a1ff:fe32:cb0b’); – IPv6
Query OK, 1 row affected (0.009 sec)
MariaDB [test]> insert into inet6_test values(’::192.168.60.100’); – IPv4 compatible
Query OK, 1 row affected (0.001 sec)
MariaDB [test]> insert into inet6_test values(’::ffff:192.168.60.100’); – IPv4 mapped
Query OK, 1 row affected (0.001 sec)
MariaDB [test]> SELECT ip, if(IS_IPV4_COMPAT(ip), ’deprecated’, ’OK’) FROM inet6_test;
+–––––––––––––––––––––––––––+––––––––––––––––––––––––––––––––––––––––––––+
| ip | if(IS_IPV4_COMPAT(ip), ’deprecated’, ’OK’) |
+–––––––––––––––––––––––––––+––––––––––––––––––––––––––––––––––––––––––––+
| fe80::e43b:a1ff:fe32:cb0b | OK |
| ::192.168.60.100 | deprecated |
| ::ffff:192.168.60.100 | OK |
+–––––––––––––––––––––––––––+––––––––––––––––––––––––––––––––––––––––––––+
3 rows in set (0.002 sec)
INET6 data type
14
• Normal table scan
1
2
3
4
5
Locked
1
2
Wait
[innodb_]lock_wait_timeout seconds
WAIT and NOWAIT
15
• WAIT n
1
2
3
4
5
Locked
1
2
Wait
n seconds
WAIT and NOWAIT
15
• NOWAIT or WAIT 0
1
2
3
4
5
Locked
1
2
Error
WAIT and NOWAIT
15
Optimizer and SQL Improvements
• Your own aggregate functions
Aggregate stored functions
17
• Your own aggregate functions
MariaDB [test]> create aggregate function count_positive(val int) returns int
-> begin
-> declare result int unsigned default 0;
-> declare exit handler for not found return result;
-> main_loop:
-> loop
-> fetch group next row;
-> if sign(val) = 1 then
-> set result := result + 1;
-> end if;
-> end loop;
-> end
-> |
Query OK, 0 rows affected (0.001 sec)
Aggregate stored functions
17
• Your own aggregate functions
MariaDB [test]> select color, count_positive(num) from numbers group by color;
+–––––––+–––––––––––––––––––––+
| color | count_positive(num) |
+–––––––+–––––––––––––––––––––+
| NULL | 1 |
| blue | 0 |
| green | 2 |
| red | 2 |
+–––––––+–––––––––––––––––––––+
4 rows in set (0.001 sec)
MariaDB [test]> select group_concat(num) from numbers;
+–––––––––––––––––––––––––+
| group_concat(num) |
+–––––––––––––––––––––––––+
| 1,-2,3,-4,5,-6,7,-8,9,0 |
+–––––––––––––––––––––––––+
1 row in set (0.001 sec)
Aggregate stored functions
17
• Histogram-based statistics
•
And MariaDB-only independent table statistics
• ANALYZE
• CTEs and WITH statement
• Window functions
• CHECK constraint
• Roles
MariaDB 10.0+ Features, Announced in MySQL 8.0
18
1 2 3 4 5 6 7 8 9 10
0
200
400
600
800
Data Distribution
19
1 2 3 4 5 6 7 8 9 10
0
200
400
600
800
Indexes: Cardinality
20
1 2 3 4 5 6 7 8 9 10
0
0.2
0.4
0.6
0.8
1
Same Data in Histograms
21
Based on MySQL bug #78651
• EXPLAIN is telling lies
MariaDB [test]> explain select * from ol
-> where thread_id=10432 and site_id != 9939 order by id limit 3G
*************************** 1. row ***************************
id: 1
select_type: SIMPLE
table: ol
type: index
possible_keys: thread_id
key: PRIMARY
key_len: 4
ref: NULL
rows: 33
Extra: Using where
ANALYZE
22
Based on MySQL bug #78651
• ANALYZE executes the statement
MariaDB [test]> analyze select * from ol
-> where thread_id=10432 and site_id != 9939 order by id limit 3G
*************************** 1. row ***************************
...
type: index
possible_keys: thread_id
key: PRIMARY
key_len: 4
ref: const
rows: 100000
r_rows: 100000.00
filtered: 8.96
r_filtered: 0.00
Extra: Using where
ANALYZE
22
• CTEs
•
Not recursive
MariaDB [employees]> with
-> dept_data as
-> (select emp_no, dept_name from dept_emp join departments using (dept_no)
-> select first_name, last_name, dept_name
-> from employees join dept_data using(emp_no)
-> order by hire_date desc limit 3;
+––––––––––––+–––––––––––+––––––––––––––––––––+
| first_name | last_name | dept_name |
+––––––––––––+–––––––––––+––––––––––––––––––––+
| Bikash | Covnot | Quality Management |
| Yucai | Gerlach | Production |
| Hideyuki | Delgrande | Development |
+––––––––––––+–––––––––––+––––––––––––––––––––+
3 rows in set (0.00 sec)
SQL DML
23
• CTEs
• Recursive
MariaDB [employees]> with recursive rand_generator(id, rand_value) as
-> (select 1, rand()
-> union all select id+1, rand()
-> from rand_generator where id < 5)
-> select * from rand_generator;
+––––––+–––––––––––––––––––––+
| id | rand_value |
+––––––+–––––––––––––––––––––+
| 1 | 0.5599308382346582 |
| 2 | 0.2151867702744778 |
| 3 | 0.39614136740205935 |
| 4 | 0.33514655692050843 |
| 5 | 0.4873087131300091 |
+––––––+–––––––––––––––––––––+
5 rows in set (0.00 sec)
SQL DML
23
• Window functions
MariaDB [employees]> select
-> row_number() over win as id, dept_no, dept_name from departments
-> window win
-> as (order by dept_no);
+––––+–––––––––+––––––––––––––––––––+
| id | dept_no | dept_name |
+––––+–––––––––+––––––––––––––––––––+
| 1 | d001 | Marketing |
| 2 | d002 | Finance |
| 3 | d003 | Human Resources |
| 4 | d004 | Production |
| 5 | d005 | Development |
| 6 | d006 | Quality Management |
| 7 | d007 | Sales |
| 8 | d008 | Research |
| 9 | d009 | Customer Service |
+––––+–––––––––+––––––––––––––––––––+
SQL DML
23
• Custom rules validation
CHECK Constraint
24
• Custom rules validation
MariaDB [test]> create table even (even_value int check(even_value % 2 = 0)) engine=innodb;
Query OK, 0 rows affected (0.004 sec)
MariaDB [test]> insert into even value(2);
Query OK, 1 row affected (0.003 sec)
MariaDB [test]> insert into even value(1);
ERROR 4025 (23000): CONSTRAINT ‘even.even_value‘ failed for ‘test‘.‘even‘
CHECK Constraint
24
• No need to repeat GRANT
MariaDB [test]> create role read_only, admin;
Query OK, 0 rows affected (0.001 sec)
MariaDB [test]> grant select on *.* to read_only;
Query OK, 0 rows affected (0.001 sec)
MariaDB [test]> grant super on *.* to admin;
Query OK, 0 rows affected (0.001 sec)
Roles
25
• No need to repeat GRANT
MariaDB [test]> create user sveta;
Query OK, 0 rows affected (0.001 sec)
MariaDB [test]> create user kaj;
Query OK, 0 rows affected (0.001 sec)
MariaDB [test]> create user privileged;
Query OK, 0 rows affected (0.001 sec)
MariaDB [test]> grant read_only to sveta;
Query OK, 0 rows affected (0.001 sec)
MariaDB [test]> grant read_only to kaj;
Query OK, 0 rows affected (0.001 sec)
MariaDB [test]> grant admin to privileged;
Query OK, 0 rows affected (0.001 sec)
Roles
25
• No need to repeat GRANT
• DEFAULT roles
Roles
25
• New versions have new features
• MariaDB implements advanced features early
• Upgrade to new version
•
Explore all MariaDB advantages!
Conclusions
26
•
The S3 Storage Engine
MariaDB ColumnStore
Rewinding time with System Versioned Tables
Invisible Columns
Sequences
INET6 Data Type
WAIT and NOWAIT
More Details
27
•
Stored Aggregate Functions
Histogram-Based Statistics
Engine Independent Statistics
ANALYZE Statement
Common Table Expressions
Window Functions
More Details
27
•
CHECK Constraints
Roles
More Details
27
www.slideshare.net/SvetaSmirnova
twitter.com/svetsmirnova
github.com/svetasmirnova
Thank you!
28
DATABASE PERFORMANCE
MATTERS

Contenu connexe

Tendances

MySQL Performance Schema in 20 Minutes
 MySQL Performance Schema in 20 Minutes MySQL Performance Schema in 20 Minutes
MySQL Performance Schema in 20 Minutes
Sveta Smirnova
 
How to Avoid Pitfalls in Schema Upgrade with Percona XtraDB Cluster
How to Avoid Pitfalls in Schema Upgrade with Percona XtraDB ClusterHow to Avoid Pitfalls in Schema Upgrade with Percona XtraDB Cluster
How to Avoid Pitfalls in Schema Upgrade with Percona XtraDB Cluster
Sveta Smirnova
 
Highload Perf Tuning
Highload Perf TuningHighload Perf Tuning
Highload Perf Tuning
HighLoad2009
 
MySQL Indexing - Best practices for MySQL 5.6
MySQL Indexing - Best practices for MySQL 5.6MySQL Indexing - Best practices for MySQL 5.6
MySQL Indexing - Best practices for MySQL 5.6
MYXPLAIN
 

Tendances (20)

A Billion Goods in a Few Categories: When Optimizer Histograms Help and When ...
A Billion Goods in a Few Categories: When Optimizer Histograms Help and When ...A Billion Goods in a Few Categories: When Optimizer Histograms Help and When ...
A Billion Goods in a Few Categories: When Optimizer Histograms Help and When ...
 
Performance Schema in Action: demo
Performance Schema in Action: demoPerformance Schema in Action: demo
Performance Schema in Action: demo
 
Optimizer Histograms: When they Help and When Do Not?
Optimizer Histograms: When they Help and When Do Not?Optimizer Histograms: When they Help and When Do Not?
Optimizer Histograms: When they Help and When Do Not?
 
Introduction into MySQL Query Tuning
Introduction into MySQL Query TuningIntroduction into MySQL Query Tuning
Introduction into MySQL Query Tuning
 
Introduction into MySQL Query Tuning for Dev[Op]s
Introduction into MySQL Query Tuning for Dev[Op]sIntroduction into MySQL Query Tuning for Dev[Op]s
Introduction into MySQL Query Tuning for Dev[Op]s
 
Billion Goods in Few Categories: How Histograms Save a Life?
Billion Goods in Few Categories: How Histograms Save a Life?Billion Goods in Few Categories: How Histograms Save a Life?
Billion Goods in Few Categories: How Histograms Save a Life?
 
MySQL Performance Schema in 20 Minutes
 MySQL Performance Schema in 20 Minutes MySQL Performance Schema in 20 Minutes
MySQL Performance Schema in 20 Minutes
 
MySQL Performance Schema in Action
MySQL Performance Schema in ActionMySQL Performance Schema in Action
MySQL Performance Schema in Action
 
How to Avoid Pitfalls in Schema Upgrade with Percona XtraDB Cluster
How to Avoid Pitfalls in Schema Upgrade with Percona XtraDB ClusterHow to Avoid Pitfalls in Schema Upgrade with Percona XtraDB Cluster
How to Avoid Pitfalls in Schema Upgrade with Percona XtraDB Cluster
 
Highload Perf Tuning
Highload Perf TuningHighload Perf Tuning
Highload Perf Tuning
 
Performance Schema for MySQL Troubleshooting
Performance Schema for MySQL TroubleshootingPerformance Schema for MySQL Troubleshooting
Performance Schema for MySQL Troubleshooting
 
Using Apache Spark and MySQL for Data Analysis
Using Apache Spark and MySQL for Data AnalysisUsing Apache Spark and MySQL for Data Analysis
Using Apache Spark and MySQL for Data Analysis
 
Preparse Query Rewrite Plugins
Preparse Query Rewrite PluginsPreparse Query Rewrite Plugins
Preparse Query Rewrite Plugins
 
New index features in MySQL 8
New index features in MySQL 8New index features in MySQL 8
New index features in MySQL 8
 
0888 learning-mysql
0888 learning-mysql0888 learning-mysql
0888 learning-mysql
 
MySQL 8 for Developers
MySQL 8 for DevelopersMySQL 8 for Developers
MySQL 8 for Developers
 
Need for Speed: Mysql indexing
Need for Speed: Mysql indexingNeed for Speed: Mysql indexing
Need for Speed: Mysql indexing
 
MySQL Indexing - Best practices for MySQL 5.6
MySQL Indexing - Best practices for MySQL 5.6MySQL Indexing - Best practices for MySQL 5.6
MySQL Indexing - Best practices for MySQL 5.6
 
How to Avoid Pitfalls in Schema Upgrade with Galera
How to Avoid Pitfalls in Schema Upgrade with GaleraHow to Avoid Pitfalls in Schema Upgrade with Galera
How to Avoid Pitfalls in Schema Upgrade with Galera
 
Common Table Expressions in MariaDB 10.2
Common Table Expressions in MariaDB 10.2Common Table Expressions in MariaDB 10.2
Common Table Expressions in MariaDB 10.2
 

Similaire à Modern solutions for modern database load: improvements in the latest MariaDB versions

MariaDB with SphinxSE
MariaDB with SphinxSEMariaDB with SphinxSE
MariaDB with SphinxSE
Colin Charles
 
Applied Partitioning And Scaling Your Database System Presentation
Applied Partitioning And Scaling Your Database System PresentationApplied Partitioning And Scaling Your Database System Presentation
Applied Partitioning And Scaling Your Database System Presentation
Richard Crowley
 
15 protips for mysql users pfz
15 protips for mysql users   pfz15 protips for mysql users   pfz
15 protips for mysql users pfz
Joshua Thijssen
 

Similaire à Modern solutions for modern database load: improvements in the latest MariaDB versions (20)

MySQLinsanity
MySQLinsanityMySQLinsanity
MySQLinsanity
 
What is MariaDB Server 10.3?
What is MariaDB Server 10.3?What is MariaDB Server 10.3?
What is MariaDB Server 10.3?
 
Curso de MySQL 5.7
Curso de MySQL 5.7Curso de MySQL 5.7
Curso de MySQL 5.7
 
Percona Live 4/15/15: Transparent sharding database virtualization engine (DVE)
Percona Live 4/15/15: Transparent sharding database virtualization engine (DVE)Percona Live 4/15/15: Transparent sharding database virtualization engine (DVE)
Percona Live 4/15/15: Transparent sharding database virtualization engine (DVE)
 
MySQL SQL Tutorial
MySQL SQL TutorialMySQL SQL Tutorial
MySQL SQL Tutorial
 
MySQL Cookbook: Recipes for Developers, Alkin Tezuysal and Sveta Smirnova - P...
MySQL Cookbook: Recipes for Developers, Alkin Tezuysal and Sveta Smirnova - P...MySQL Cookbook: Recipes for Developers, Alkin Tezuysal and Sveta Smirnova - P...
MySQL Cookbook: Recipes for Developers, Alkin Tezuysal and Sveta Smirnova - P...
 
MySQL Cookbook: Recipes for Developers
MySQL Cookbook: Recipes for DevelopersMySQL Cookbook: Recipes for Developers
MySQL Cookbook: Recipes for Developers
 
MySQL Features
MySQL FeaturesMySQL Features
MySQL Features
 
MySQL Kitchen : spice up your everyday SQL queries
MySQL Kitchen : spice up your everyday SQL queriesMySQL Kitchen : spice up your everyday SQL queries
MySQL Kitchen : spice up your everyday SQL queries
 
5_MariaDB_What's New in MariaDB Server 10.2 and Big Data Analytics with Maria...
5_MariaDB_What's New in MariaDB Server 10.2 and Big Data Analytics with Maria...5_MariaDB_What's New in MariaDB Server 10.2 and Big Data Analytics with Maria...
5_MariaDB_What's New in MariaDB Server 10.2 and Big Data Analytics with Maria...
 
MySQL 5.7 innodb_enhance_partii_20160527
MySQL 5.7 innodb_enhance_partii_20160527MySQL 5.7 innodb_enhance_partii_20160527
MySQL 5.7 innodb_enhance_partii_20160527
 
MariaDB with SphinxSE
MariaDB with SphinxSEMariaDB with SphinxSE
MariaDB with SphinxSE
 
16 MySQL Optimization #burningkeyboards
16 MySQL Optimization #burningkeyboards16 MySQL Optimization #burningkeyboards
16 MySQL Optimization #burningkeyboards
 
Perf Tuning Short
Perf Tuning ShortPerf Tuning Short
Perf Tuning Short
 
Mysql basics1
Mysql basics1Mysql basics1
Mysql basics1
 
OSMC 2008 | Monitoring MySQL by Geert Vanderkelen
OSMC 2008 | Monitoring MySQL by Geert VanderkelenOSMC 2008 | Monitoring MySQL by Geert Vanderkelen
OSMC 2008 | Monitoring MySQL by Geert Vanderkelen
 
Applied Partitioning And Scaling Your Database System Presentation
Applied Partitioning And Scaling Your Database System PresentationApplied Partitioning And Scaling Your Database System Presentation
Applied Partitioning And Scaling Your Database System Presentation
 
Quick Wins
Quick WinsQuick Wins
Quick Wins
 
Parallel Query in AWS Aurora MySQL
Parallel Query in AWS Aurora MySQLParallel Query in AWS Aurora MySQL
Parallel Query in AWS Aurora MySQL
 
15 protips for mysql users pfz
15 protips for mysql users   pfz15 protips for mysql users   pfz
15 protips for mysql users pfz
 

Plus de Sveta Smirnova

MySQL Test Framework для поддержки клиентов и верификации багов
MySQL Test Framework для поддержки клиентов и верификации баговMySQL Test Framework для поддержки клиентов и верификации багов
MySQL Test Framework для поддержки клиентов и верификации багов
Sveta Smirnova
 
Современному хайлоду - современные решения: MySQL 8.0 и улучшения Percona
Современному хайлоду - современные решения: MySQL 8.0 и улучшения PerconaСовременному хайлоду - современные решения: MySQL 8.0 и улучшения Percona
Современному хайлоду - современные решения: MySQL 8.0 и улучшения Percona
Sveta Smirnova
 

Plus de Sveta Smirnova (12)

MySQL 2024: Зачем переходить на MySQL 8, если в 5.х всё устраивает?
MySQL 2024: Зачем переходить на MySQL 8, если в 5.х всё устраивает?MySQL 2024: Зачем переходить на MySQL 8, если в 5.х всё устраивает?
MySQL 2024: Зачем переходить на MySQL 8, если в 5.х всё устраивает?
 
Database in Kubernetes: Diagnostics and Monitoring
Database in Kubernetes: Diagnostics and MonitoringDatabase in Kubernetes: Diagnostics and Monitoring
Database in Kubernetes: Diagnostics and Monitoring
 
MySQL Database Monitoring: Must, Good and Nice to Have
MySQL Database Monitoring: Must, Good and Nice to HaveMySQL Database Monitoring: Must, Good and Nice to Have
MySQL Database Monitoring: Must, Good and Nice to Have
 
MySQL Performance for DevOps
MySQL Performance for DevOpsMySQL Performance for DevOps
MySQL Performance for DevOps
 
MySQL Test Framework для поддержки клиентов и верификации багов
MySQL Test Framework для поддержки клиентов и верификации баговMySQL Test Framework для поддержки клиентов и верификации багов
MySQL Test Framework для поддержки клиентов и верификации багов
 
MySQL Cookbook: Recipes for Your Business
MySQL Cookbook: Recipes for Your BusinessMySQL Cookbook: Recipes for Your Business
MySQL Cookbook: Recipes for Your Business
 
Производительность MySQL для DevOps
 Производительность MySQL для DevOps Производительность MySQL для DevOps
Производительность MySQL для DevOps
 
How Safe is Asynchronous Master-Master Setup?
How Safe is Asynchronous Master-Master Setup?How Safe is Asynchronous Master-Master Setup?
How Safe is Asynchronous Master-Master Setup?
 
Современному хайлоду - современные решения: MySQL 8.0 и улучшения Percona
Современному хайлоду - современные решения: MySQL 8.0 и улучшения PerconaСовременному хайлоду - современные решения: MySQL 8.0 и улучшения Percona
Современному хайлоду - современные решения: MySQL 8.0 и улучшения Percona
 
How Safe is Asynchronous Master-Master Setup?
 How Safe is Asynchronous Master-Master Setup? How Safe is Asynchronous Master-Master Setup?
How Safe is Asynchronous Master-Master Setup?
 
Что нужно знать о трёх топовых фичах MySQL
Что нужно знать  о трёх топовых фичах  MySQLЧто нужно знать  о трёх топовых фичах  MySQL
Что нужно знать о трёх топовых фичах MySQL
 
Why MySQL Replication Fails, and How to Get it Back
Why MySQL Replication Fails, and How to Get it BackWhy MySQL Replication Fails, and How to Get it Back
Why MySQL Replication Fails, and How to Get it Back
 

Dernier

introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
VishalKumarJha10
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
mohitmore19
 

Dernier (20)

call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
The Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdfThe Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdf
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
Pharm-D Biostatistics and Research methodology
Pharm-D Biostatistics and Research methodologyPharm-D Biostatistics and Research methodology
Pharm-D Biostatistics and Research methodology
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfExploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdf
 

Modern solutions for modern database load: improvements in the latest MariaDB versions

  • 1. MariaDB Improvements in the Latest Versions September 14-16, 2020 Sveta Smirnova
  • 2. • MySQL Support Engineer • Author of • MySQL Troubleshooting • JSON UDF functions • FILTER clause for MySQL • Speaker • Percona Live, OOW, Fosdem, DevConf, HighLoad... Sveta Smirnova 2
  • 3. •Storage Improvements •Optimizer and SQL Improvements Table of Contents 3
  • 4. 1995 Initial Release by MySQL AB MySQL 4
  • 5. 1995 Initial Release by MySQL AB 2006 Percona Server for MySQL MySQL 4
  • 6. 1995 Initial Release by MySQL AB 2006 Percona Server for MySQL 2008 Sun owns MySQL MySQL 4
  • 7. 1995 Initial Release by MySQL AB 2006 Percona Server for MySQL 2008 Sun owns MySQL 2010 Oracle owns Sun and MySQL MySQL 4
  • 8. 1995 Initial Release by MySQL AB 2006 Percona Server for MySQL 2008 Sun owns MySQL 2010 Oracle owns Sun and MySQL 2010 MariaDB MySQL 4
  • 9. • Started as fork of MySQL MariaDB 5
  • 10. • Started as fork of MySQL • Independent product MariaDB 5
  • 11. • Started as fork of MySQL • Independent product • Hundreds of unique features MariaDB 5
  • 12. • Started as fork of MySQL • Independent product • Hundreds of unique features • Important improvements are backported • from MySQL MariaDB 5
  • 13. • Features, ported from MySQL 8.0 This Talk 6
  • 14. • Features, ported from MySQL 8.0 • Another talk MySQL 8.0 and Percona Improvements This Talk 6
  • 15. • Features, ported from MySQL 8.0 • Another talk MySQL 8.0 and Percona Improvements • MariaDB Unique Features • Storage Improvements Alternative storage engines Others • Optimizer Improvements Advanced SQL Performance and diagnostics This Talk 6
  • 18. • Storage Engine • Data stored on Amazon S3 S3 8
  • 19. • Storage Engine • Data stored on Amazon S3 • Any original engine ALTER TABLE my_table ENGINE=S3; ALTER TABLE my_table ENGINE=INNODB; ALTER TABLE my_table ENGINE=S3; S3 8
  • 20. • Storage Engine • Data stored on Amazon S3 • Any original engine • Underlying engine is Aria S3 8
  • 21. • Storage Engine • Data stored on Amazon S3 • Any original engine • Underlying engine is Aria • Read-only tables S3 8
  • 22. • Storage Engine • Data stored on Amazon S3 • Any original engine • Underlying engine is Aria • Read-only tables • Shared and separated storage for replication S3 8
  • 23. • Storage Engine • Data stored on Amazon S3 • Any original engine • Underlying engine is Aria • Read-only tables • Shared and separated storage for replication • Own layer to connect to S3: libmarias3 S3 8
  • 24. • Storage Engine • Available since 2017 as a plugin • Part of 10.5 Community Server release ColumnStore 9
  • 25. • Columnar Storage Engine • Based on InfiniDB ColumnStore 9
  • 26. • Designed for parallel processing • SQL interface • JOINs with SQL engines (InnoDB etc.) • Easy integration with existent SQL setup • All advantages of the column storage ColumnStore 9
  • 29. • PITR on the fly System-Versioned Tables 11
  • 30. • PITR on the fly • Create a versioned table MariaDB [test]> alter table employees ADD SYSTEM VERSIONING; Query OK, 300024 rows affected (1.060 sec) Records: 300024 Duplicates: 0 Warnings: 0 System-Versioned Tables 11
  • 31. • PITR on the fly • Check table options MariaDB [test]> show create table employeesG *************************** 1. row *************************** Table: employees Create Table: CREATE TABLE ‘employees‘ ( ‘emp_no‘ int(11) NOT NULL, ‘birth_date‘ date NOT NULL, ‘first_name‘ varchar(14) COLLATE utf8mb4_unicode_ci NOT NULL, ‘last_name‘ varchar(16) COLLATE utf8mb4_unicode_ci NOT NULL, ‘gender‘ enum(’M’,’F’) COLLATE utf8mb4_unicode_ci NOT NULL, ‘hire_date‘ date NOT NULL, PRIMARY KEY (‘emp_no‘) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci WITH SYSTEM VERSIONING 1 row in set (0.001 sec) System-Versioned Tables 11
  • 32. • PITR on the fly • Perform activities MariaDB [test]> select count(*) from employees where hire_date < ’1986-01-01’; +––––––––––+ | count(*) | +––––––––––+ | 35316 | +––––––––––+ 1 row in set (0.188 sec) MariaDB [test]> delete from employees where hire_date < ’1986-01-01’; Query OK, 35316 rows affected (0.837 sec) System-Versioned Tables 11
  • 33. • PITR on the fly • Lost rows MariaDB [test]> select count(*) from employees where hire_date < ’1986-01-01’; +––––––––––+ | count(*) | +––––––––––+ | 0 | +––––––––––+ 1 row in set (0.103 sec) System-Versioned Tables 11
  • 34. • PITR on the fly • Restore deleted rows MariaDB [test]> insert into employees select * FROM employees -> FOR SYSTEM_TIME between (now() - interval 1 hour) and now() -> where hire_date < ’1986-01-01’; Query OK, 35316 rows affected (0.721 sec) Records: 35316 Duplicates: 0 Warnings: 0 MariaDB [test]> select count(*) from employees where hire_date < ’1986-01-01’; +––––––––––+ | count(*) | +––––––––––+ | 35316 | +––––––––––+ 1 row in set (0.216 sec) System-Versioned Tables 11
  • 35. • Change history • PITR on the fly • Tunable Time Transaction ID With History, stored separately Paritioned With columns, excluded from versioning With time periods: application history With both system and application period levels System-Versioned Tables 11
  • 36. • Columns, not visible for SELECT * MariaDB [test]> alter table employees add column address JSON invisible; Query OK, 0 rows affected (0.005 sec) Records: 0 Duplicates: 0 Warnings: 0 – Update address for some employees MariaDB [test]> select * from employees limit 3; +––––––––+––––––––––––+––––––––––––+–––––––––––+––––––––+––––––––––––+ | emp_no | birth_date | first_name | last_name | gender | hire_date | +––––––––+––––––––––––+––––––––––––+–––––––––––+––––––––+––––––––––––+ | 10001 | 1953-09-02 | Georgi | Facello | M | 1986-06-26 | | 10002 | 1964-06-02 | Bezalel | Simmel | F | 1985-11-21 | | 10003 | 1959-12-03 | Parto | Bamford | M | 1986-08-28 | +––––––––+––––––––––––+––––––––––––+–––––––––––+––––––––+––––––––––––+ 3 rows in set (0.001 sec) Invisible columns 12
  • 37. • Columns, not visible for SELECT * • Accessible for the direct query MariaDB [test]> select first_name, last_name, json_extract(address, "$.City") -> from employees where address is not null; +––––––––––––+–––––––––––+–––––––––––––––––––––––––––––––––+ | first_name | last_name | json_extract(address, "$.City") | +––––––––––––+–––––––––––+–––––––––––––––––––––––––––––––––+ | Tianruo | Jenevein | "Espoo" | | Dulce | Kolinko | "Espoo" | | Masasuke | Gill | "Espoo" | | Toshimi | Karner | "Espoo" | | Danco | Yetto | "Espoo" | +––––––––––––+–––––––––––+–––––––––––––––––––––––––––––––––+ 5 rows in set (0.173 sec) Invisible columns 12
  • 38. MariaDB [test]> create sequence odds start with 1 increment by 2; Query OK, 0 rows affected (0.001 sec) MariaDB [test]> create sequence evens start with 2 increment by 2; Query OK, 0 rows affected (0.001 sec) MariaDB [test]> create table numbers( -> id int not null auto_increment primary key, -> odd int default next value for odds, -> even int default next value for evens -> ); Query OK, 0 rows affected (0.004 sec) Sequences 13
  • 39. MariaDB [test]> insert into numbers values (), (), (), (), (); Query OK, 5 rows affected (0.002 sec) Records: 5 Duplicates: 0 Warnings: 0 MariaDB [test]> select * from numbers; +––––+––––––+––––––+ | id | odd | even | +––––+––––––+––––––+ | 1 | 1 | 2 | | 2 | 3 | 4 | | 3 | 5 | 6 | | 4 | 7 | 8 | | 5 | 9 | 10 | +––––+––––––+––––––+ 5 rows in set (0.001 sec) Sequences 13
  • 40. • Native IPv6 support MariaDB [test]> create table inet6_test(ip inet6); Query OK, 0 rows affected (0.001 sec) MariaDB [test]> insert into inet6_test values(’fe80::e43b:a1ff:fe32:cb0b’); – IPv6 Query OK, 1 row affected (0.009 sec) MariaDB [test]> insert into inet6_test values(’::192.168.60.100’); – IPv4 compatible Query OK, 1 row affected (0.001 sec) MariaDB [test]> insert into inet6_test values(’::ffff:192.168.60.100’); – IPv4 mapped Query OK, 1 row affected (0.001 sec) MariaDB [test]> SELECT ip, if(IS_IPV4_COMPAT(ip), ’deprecated’, ’OK’) FROM inet6_test; +–––––––––––––––––––––––––––+––––––––––––––––––––––––––––––––––––––––––––+ | ip | if(IS_IPV4_COMPAT(ip), ’deprecated’, ’OK’) | +–––––––––––––––––––––––––––+––––––––––––––––––––––––––––––––––––––––––––+ | fe80::e43b:a1ff:fe32:cb0b | OK | | ::192.168.60.100 | deprecated | | ::ffff:192.168.60.100 | OK | +–––––––––––––––––––––––––––+––––––––––––––––––––––––––––––––––––––––––––+ 3 rows in set (0.002 sec) INET6 data type 14
  • 41. • Normal table scan 1 2 3 4 5 Locked 1 2 Wait [innodb_]lock_wait_timeout seconds WAIT and NOWAIT 15
  • 42. • WAIT n 1 2 3 4 5 Locked 1 2 Wait n seconds WAIT and NOWAIT 15
  • 43. • NOWAIT or WAIT 0 1 2 3 4 5 Locked 1 2 Error WAIT and NOWAIT 15
  • 44. Optimizer and SQL Improvements
  • 45. • Your own aggregate functions Aggregate stored functions 17
  • 46. • Your own aggregate functions MariaDB [test]> create aggregate function count_positive(val int) returns int -> begin -> declare result int unsigned default 0; -> declare exit handler for not found return result; -> main_loop: -> loop -> fetch group next row; -> if sign(val) = 1 then -> set result := result + 1; -> end if; -> end loop; -> end -> | Query OK, 0 rows affected (0.001 sec) Aggregate stored functions 17
  • 47. • Your own aggregate functions MariaDB [test]> select color, count_positive(num) from numbers group by color; +–––––––+–––––––––––––––––––––+ | color | count_positive(num) | +–––––––+–––––––––––––––––––––+ | NULL | 1 | | blue | 0 | | green | 2 | | red | 2 | +–––––––+–––––––––––––––––––––+ 4 rows in set (0.001 sec) MariaDB [test]> select group_concat(num) from numbers; +–––––––––––––––––––––––––+ | group_concat(num) | +–––––––––––––––––––––––––+ | 1,-2,3,-4,5,-6,7,-8,9,0 | +–––––––––––––––––––––––––+ 1 row in set (0.001 sec) Aggregate stored functions 17
  • 48. • Histogram-based statistics • And MariaDB-only independent table statistics • ANALYZE • CTEs and WITH statement • Window functions • CHECK constraint • Roles MariaDB 10.0+ Features, Announced in MySQL 8.0 18
  • 49. 1 2 3 4 5 6 7 8 9 10 0 200 400 600 800 Data Distribution 19
  • 50. 1 2 3 4 5 6 7 8 9 10 0 200 400 600 800 Indexes: Cardinality 20
  • 51. 1 2 3 4 5 6 7 8 9 10 0 0.2 0.4 0.6 0.8 1 Same Data in Histograms 21
  • 52. Based on MySQL bug #78651 • EXPLAIN is telling lies MariaDB [test]> explain select * from ol -> where thread_id=10432 and site_id != 9939 order by id limit 3G *************************** 1. row *************************** id: 1 select_type: SIMPLE table: ol type: index possible_keys: thread_id key: PRIMARY key_len: 4 ref: NULL rows: 33 Extra: Using where ANALYZE 22
  • 53. Based on MySQL bug #78651 • ANALYZE executes the statement MariaDB [test]> analyze select * from ol -> where thread_id=10432 and site_id != 9939 order by id limit 3G *************************** 1. row *************************** ... type: index possible_keys: thread_id key: PRIMARY key_len: 4 ref: const rows: 100000 r_rows: 100000.00 filtered: 8.96 r_filtered: 0.00 Extra: Using where ANALYZE 22
  • 54. • CTEs • Not recursive MariaDB [employees]> with -> dept_data as -> (select emp_no, dept_name from dept_emp join departments using (dept_no) -> select first_name, last_name, dept_name -> from employees join dept_data using(emp_no) -> order by hire_date desc limit 3; +––––––––––––+–––––––––––+––––––––––––––––––––+ | first_name | last_name | dept_name | +––––––––––––+–––––––––––+––––––––––––––––––––+ | Bikash | Covnot | Quality Management | | Yucai | Gerlach | Production | | Hideyuki | Delgrande | Development | +––––––––––––+–––––––––––+––––––––––––––––––––+ 3 rows in set (0.00 sec) SQL DML 23
  • 55. • CTEs • Recursive MariaDB [employees]> with recursive rand_generator(id, rand_value) as -> (select 1, rand() -> union all select id+1, rand() -> from rand_generator where id < 5) -> select * from rand_generator; +––––––+–––––––––––––––––––––+ | id | rand_value | +––––––+–––––––––––––––––––––+ | 1 | 0.5599308382346582 | | 2 | 0.2151867702744778 | | 3 | 0.39614136740205935 | | 4 | 0.33514655692050843 | | 5 | 0.4873087131300091 | +––––––+–––––––––––––––––––––+ 5 rows in set (0.00 sec) SQL DML 23
  • 56. • Window functions MariaDB [employees]> select -> row_number() over win as id, dept_no, dept_name from departments -> window win -> as (order by dept_no); +––––+–––––––––+––––––––––––––––––––+ | id | dept_no | dept_name | +––––+–––––––––+––––––––––––––––––––+ | 1 | d001 | Marketing | | 2 | d002 | Finance | | 3 | d003 | Human Resources | | 4 | d004 | Production | | 5 | d005 | Development | | 6 | d006 | Quality Management | | 7 | d007 | Sales | | 8 | d008 | Research | | 9 | d009 | Customer Service | +––––+–––––––––+––––––––––––––––––––+ SQL DML 23
  • 57. • Custom rules validation CHECK Constraint 24
  • 58. • Custom rules validation MariaDB [test]> create table even (even_value int check(even_value % 2 = 0)) engine=innodb; Query OK, 0 rows affected (0.004 sec) MariaDB [test]> insert into even value(2); Query OK, 1 row affected (0.003 sec) MariaDB [test]> insert into even value(1); ERROR 4025 (23000): CONSTRAINT ‘even.even_value‘ failed for ‘test‘.‘even‘ CHECK Constraint 24
  • 59. • No need to repeat GRANT MariaDB [test]> create role read_only, admin; Query OK, 0 rows affected (0.001 sec) MariaDB [test]> grant select on *.* to read_only; Query OK, 0 rows affected (0.001 sec) MariaDB [test]> grant super on *.* to admin; Query OK, 0 rows affected (0.001 sec) Roles 25
  • 60. • No need to repeat GRANT MariaDB [test]> create user sveta; Query OK, 0 rows affected (0.001 sec) MariaDB [test]> create user kaj; Query OK, 0 rows affected (0.001 sec) MariaDB [test]> create user privileged; Query OK, 0 rows affected (0.001 sec) MariaDB [test]> grant read_only to sveta; Query OK, 0 rows affected (0.001 sec) MariaDB [test]> grant read_only to kaj; Query OK, 0 rows affected (0.001 sec) MariaDB [test]> grant admin to privileged; Query OK, 0 rows affected (0.001 sec) Roles 25
  • 61. • No need to repeat GRANT • DEFAULT roles Roles 25
  • 62. • New versions have new features • MariaDB implements advanced features early • Upgrade to new version • Explore all MariaDB advantages! Conclusions 26
  • 63. • The S3 Storage Engine MariaDB ColumnStore Rewinding time with System Versioned Tables Invisible Columns Sequences INET6 Data Type WAIT and NOWAIT More Details 27
  • 64. • Stored Aggregate Functions Histogram-Based Statistics Engine Independent Statistics ANALYZE Statement Common Table Expressions Window Functions More Details 27