SlideShare a Scribd company logo
1 of 19
Download to read offline
[some] Optimizer features
in recent releases
of other databases
Sergei Petrunia
Barcelona ACM
October 2019
Optimizer/Executor
in MySQL 8.0.x
MySQL 8.0
MySQL 8.0.n
- Iterator-based Executor (introduced
gradually)
MySQL 8.0.13 (2018-10-22, GA)
- Skip Scan (contribution from Facebook)
MySQL 8.0.14 (2019-01-21, GA)
- LATERAL support
MySQL 8.0.17 (2019-07-22, GA)
- Multi-valued indexes for JSON
- NOT IN/EXISTS/.. -> anti-join
- EXISTS -> Semi-join conversion
- [Anti-]semi-join conversion IS TRUE/IS NULL
- Semi-join optimization for subqueries in the
ON expressions
MySQL 8.0.18 (2019-10-14, GA)
- Hash join
- EXPLAIN ANALYZE
Iterator-based executor
● The idea: switch server internals to the init()/get_next() interface
– Unifies all access methods (quick selects, full scans, NL-joins, etc)
– A textbook-like approach, similar to PostgreSQL
– Pay-offs?
●
Cursors
●
Flexibility allows further development
●
New EXPLAIN form, EXPLAIN FORMAT=TREE
● Doesn’t handle all SQL features yet
– Handles semi-join subqueries
– Doesn’t handle outer joins.
– Doesn’t handle certain kinds of non-indexed joins?
EXPLAIN ANALYZE
● Overlapping functionality with MariaDB’s ANALYZE (since 10.1)
● Only works with Iterator-based executor
● Doesn’t [yet] work with
– SELECT queries not using the iterator-based executor
●
LEFT JOINs
●
...
– UPDATE/DELETE/etc
ANALYZE in MariaDB
select *
from ten, t1, t2
where
ten.col1 < 7 and
t1.key1=ten.a and
t2.key1=t1.a
+------+-------------+-------+------+---------------+------+---------+-----------+------+--------+----------+------------+-----------
| id   | select_type | table | type | possible_keys | key  | key_len | ref       | rows | r_rows | filtered | r_filtered | Extra     
+------+-------------+-------+------+---------------+------+---------+-----------+------+--------+----------+------------+-----------
|    1 | SIMPLE      | ten   | ALL  | PRIMARY       | NULL | NULL    | NULL      | 10   | 10.00  |   100.00 |      70.00 | Using wher
|    1 | SIMPLE      | t1    | ref  | key1          | key1 | 5       | j20.ten.a | 1    | 2.86   |   100.00 |     100.00 | Using wher
|    1 | SIMPLE      | t2    | ref  | key1          | key1 | 5       | j20.t1.a  | 1    | 10.00  |   100.00 |     100.00 |           
+------+-------------+-------+------+---------------+------+---------+-----------+------+--------+----------+------------+-----------
EXPLAIN ANALYZE
select *
from ten, t1, t2
where
ten.col1 < 7 and
t1.key1=ten.a and
t2.key1=t1.a
-> Nested loop inner join (cost=3.58 rows=3) (actual time=0.882..18.963 rows=200 loops=1)
-> Nested loop inner join (cost=2.42 rows=3) (actual time=0.648..3.992 rows=20 loops=1)
-> Filter: (ten.col1 < 7) (cost=1.25 rows=3) (actual time=0.303..0.433 rows=7 loops=1)
-> Table scan on ten (cost=1.25 rows=10) (actual time=0.296..0.394 rows=10 loops=1)
-> Filter: (t1.a is not null) (cost=0.28 rows=1) (actual time=0.178..0.504 rows=3 loops=7)
-> Index lookup on t1 using key1 (key1=ten.a) (cost=0.28 rows=1) (actual time=0.176..0.497 rows=3 loops=7)
-> Index lookup on t2 using key1 (key1=t1.a) (cost=0.28 rows=1) (actual time=0.155..0.735 rows=10 loops=20)
EXPLAIN ANALYZE
select *
from ten, t1, t2
where
ten.col1 < 7 and
t1.key1=ten.a and
t2.key1=t1.a
-> Nested loop inner join (cost=3.58 rows=3) (actual time=0.882..18.963 rows=200 loops=1)
-> Nested loop inner join (cost=2.42 rows=3) (actual time=0.648..3.992 rows=20 loops=1)
-> Filter: (ten.col1 < 7) (cost=1.25 rows=3) (actual time=0.303..0.433 rows=7 loops=1)
-> Table scan on ten (cost=1.25 rows=10) (actual time=0.296..0.394 rows=10 loops=1)
-> Filter: (t1.a is not null) (cost=0.28 rows=1) (actual time=0.178..0.504 rows=3 loops=7)
-> Index lookup on t1 using key1 (key1=ten.a) (cost=0.28 rows=1) (actual time=0.176..0.497 rows=3 loops=7)
-> Index lookup on t2 using key1 (key1=t1.a) (cost=0.28 rows=1) (actual time=0.155..0.735 rows=10 loops=20)
EXPLAIN ANALYZE
select *
from ten, t1, t2
where
ten.col1 < 7 and
t1.key1=ten.a and
t2.key1=t1.a
-> Nested loop inner join (cost=3.58 rows=3) (actual time=0.882..18.963 rows=200 loops=1)
-> Nested loop inner join (cost=2.42 rows=3) (actual time=0.648..3.992 rows=20 loops=1)
-> Filter: (ten.col1 < 7) (cost=1.25 rows=3) (actual time=0.303..0.433 rows=7 loops=1)
-> Table scan on ten (cost=1.25 rows=10) (actual time=0.296..0.394 rows=10 loops=1)
-> Filter: (t1.a is not null) (cost=0.28 rows=1) (actual time=0.178..0.504 rows=3 loops=7)
-> Index lookup on t1 using key1 (key1=ten.a) (cost=0.28 rows=1) (actual time=0.176..0.497 rows=3 loops=7)
-> Index lookup on t2 using key1 (key1=t1.a) (cost=0.28 rows=1) (actual time=0.155..0.735 rows=10 loops=20)
(actual time=0.176..0.497 rows=3 loops=7)
Convert NOT IN/EXISTS to anti-join
● Before: subquery predicate attached as early as possible
– Subquery execution short-cuts as soon as match is found
● Now: anti-join operation
– Participates in join optimization (possiblity for better plans?)
– Potentially, could benefit from join algorithms (BKA, hash
join, etc)
●
Not sure if it actually does
Convert EXISTS(...) to semi-join
● MariaDB: similar feature in 10.0, “EXISTS->IN conversion”
– Trivial correlation detection/removal works in both
– But MariaDB’s EXISTS->IN works for non-semi-joins, too.
Hash Join
● It’s a “Grace Hash Join” (correction by Igor: not quite!)
– Theoretically should be better than “BNL-H” we have
●
One read pass, hash table spills over to disk
● It uses the “iterator interface”
– Doesn’t support certain SQL features
●
Left join, etc..
– Supports semi-join
● Need to study this further
Optimizer in PostgreSQL
PostgreSQL, relevant features in recent versions
PostgreSQL 11, 2018-10-18
●
Improved partitioning
●
Improved query parallelism
●
Parallel index creation
●
JIT compilation for expressions
PostgreSQL 12, 2019-10-03
●
Non-recursive CTEs are now inlined
●
MCV statistics for multiple columns
●
JSONPath (but not indexing)
●
llvm JIT is enabled by default if compiled-in
PostgreSQL 9.6, 2016-09-29
●
Parallel query support
PostgreSQL 10, 2017-10-05
●
Logical replication
●
Improved query parallelism
●
Multi-column statistics:
correlation ratio, #distinct_values
Inlining non-recursive CTEs
● Before PostgreSQL 12: CTE is materialized and is an “optimization barrier”
19
CTE Merge Condition
pushdown
CTE reuse
MariaDB 10.2 ✔ ✔ ✘
MS SQL Server ✔ ✔ ✘
PostgreSQL ✘ ✘ ✔
MySQL 8.0.0 ✔ ✘ ✔
CTE Optimizations summary
 Merge and condition pushdown are most important
 MariaDB supports them, like MS SQL.
 PostgreSQL’s approach is *weird*
 “CTEs are optimization barriers”
 MySQL: “try merging, otherwise reuse”
Q
uoting
m
y
slide
from
M
|18:
Fixed in
PostgreSQL 12
MCV statistics for multiple columns
select * from cars_for_sale where maker='Honda' and model='Civic'
select * from users where city='Moscow' and country='Russia|USA'
● Issue: correlated conditions in WHERE
CREATE STATISTICS s2 (mcv) ON col1, col2 FROM t2;
ANALYZE TABLE t2;
● Assuming independence and multipying selectivities is bad
– Bruce Momjan(?): “90% of complaints about the optimizer are about this”
● Solution: Most-Common-Values statistics for multiple columns:
● Note: the statistics (s2) is present is [auto-]recomputed
– There’s DROP STATISTICS to remove it
Parallel index creation (PostgreSQL 11)
● Use multiple threads when creating an index
– a typical objection “does this help for an IO-bound workload”?
workers speedup
1 1.00
2 2.32
4 2.87
8 3.33
● Experiment results: it depends
– col1 INT, key(col1) - less speedup (~1.5 x)
– 3-keypart key: up 3.33x speedup
● Machine
– intel i9, 8 cores/16 threads
– Intel Optane SSD 900P (~1K eur)
Parallel query execution
● Supports joins and aggregation
– Parallel table scan
– Aggregate functions
– Parallel join algoritms
● Many constructs are “parallel stoppers”
– CTEs
●
This is why my TPC-DS benchmark run didn’t benefit from parallel
– ...
– TPC-H will show more speedups

More Related Content

What's hot

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.2Sergey Petrunya
 
Using histograms to get better performance
Using histograms to get better performanceUsing histograms to get better performance
Using histograms to get better performanceSergey Petrunya
 
MySQL/MariaDB query optimizer tuning tutorial from Percona Live 2013
MySQL/MariaDB query optimizer tuning tutorial from Percona Live 2013MySQL/MariaDB query optimizer tuning tutorial from Percona Live 2013
MySQL/MariaDB query optimizer tuning tutorial from Percona Live 2013Sergey Petrunya
 
0888 learning-mysql
0888 learning-mysql0888 learning-mysql
0888 learning-mysqlsabir18
 
MariaDB Optimizer - further down the rabbit hole
MariaDB Optimizer - further down the rabbit holeMariaDB Optimizer - further down the rabbit hole
MariaDB Optimizer - further down the rabbit holeSergey Petrunya
 
Mysqlconf2013 mariadb-cassandra-interoperability
Mysqlconf2013 mariadb-cassandra-interoperabilityMysqlconf2013 mariadb-cassandra-interoperability
Mysqlconf2013 mariadb-cassandra-interoperabilitySergey Petrunya
 
MariaDB: Engine Independent Table Statistics, including histograms
MariaDB: Engine Independent Table Statistics, including histogramsMariaDB: Engine Independent Table Statistics, including histograms
MariaDB: Engine Independent Table Statistics, including histogramsSergey Petrunya
 
New SQL features in latest MySQL releases
New SQL features in latest MySQL releasesNew SQL features in latest MySQL releases
New SQL features in latest MySQL releasesGeorgi Sotirov
 
Efficient Pagination Using MySQL
Efficient Pagination Using MySQLEfficient Pagination Using MySQL
Efficient Pagination Using MySQLEvan Weaver
 
MariaDB 10.0 Query Optimizer
MariaDB 10.0 Query OptimizerMariaDB 10.0 Query Optimizer
MariaDB 10.0 Query OptimizerSergey Petrunya
 
Window functions in MariaDB 10.2
Window functions in MariaDB 10.2Window functions in MariaDB 10.2
Window functions in MariaDB 10.2Sergey Petrunya
 
MariaDB 10.3 Optimizer - where does it stand
MariaDB 10.3 Optimizer - where does it standMariaDB 10.3 Optimizer - where does it stand
MariaDB 10.3 Optimizer - where does it standSergey Petrunya
 
Using Optimizer Hints to Improve MySQL Query Performance
Using Optimizer Hints to Improve MySQL Query PerformanceUsing Optimizer Hints to Improve MySQL Query Performance
Using Optimizer Hints to Improve MySQL Query Performanceoysteing
 
M|18 Understanding the Query Optimizer
M|18 Understanding the Query OptimizerM|18 Understanding the Query Optimizer
M|18 Understanding the Query OptimizerMariaDB plc
 
New features-in-mariadb-and-mysql-optimizers
New features-in-mariadb-and-mysql-optimizersNew features-in-mariadb-and-mysql-optimizers
New features-in-mariadb-and-mysql-optimizersSergey Petrunya
 
The MySQL Query Optimizer Explained Through Optimizer Trace
The MySQL Query Optimizer Explained Through Optimizer TraceThe MySQL Query Optimizer Explained Through Optimizer Trace
The MySQL Query Optimizer Explained Through Optimizer Traceoysteing
 
ANALYZE for executable statements - a new way to do optimizer troubleshooting...
ANALYZE for executable statements - a new way to do optimizer troubleshooting...ANALYZE for executable statements - a new way to do optimizer troubleshooting...
ANALYZE for executable statements - a new way to do optimizer troubleshooting...Sergey Petrunya
 
Adapting to Adaptive Plans on 12c
Adapting to Adaptive Plans on 12cAdapting to Adaptive Plans on 12c
Adapting to Adaptive Plans on 12cMauro Pagano
 
SQL Plan Directives explained
SQL Plan Directives explainedSQL Plan Directives explained
SQL Plan Directives explainedMauro Pagano
 

What's hot (19)

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
 
Using histograms to get better performance
Using histograms to get better performanceUsing histograms to get better performance
Using histograms to get better performance
 
MySQL/MariaDB query optimizer tuning tutorial from Percona Live 2013
MySQL/MariaDB query optimizer tuning tutorial from Percona Live 2013MySQL/MariaDB query optimizer tuning tutorial from Percona Live 2013
MySQL/MariaDB query optimizer tuning tutorial from Percona Live 2013
 
0888 learning-mysql
0888 learning-mysql0888 learning-mysql
0888 learning-mysql
 
MariaDB Optimizer - further down the rabbit hole
MariaDB Optimizer - further down the rabbit holeMariaDB Optimizer - further down the rabbit hole
MariaDB Optimizer - further down the rabbit hole
 
Mysqlconf2013 mariadb-cassandra-interoperability
Mysqlconf2013 mariadb-cassandra-interoperabilityMysqlconf2013 mariadb-cassandra-interoperability
Mysqlconf2013 mariadb-cassandra-interoperability
 
MariaDB: Engine Independent Table Statistics, including histograms
MariaDB: Engine Independent Table Statistics, including histogramsMariaDB: Engine Independent Table Statistics, including histograms
MariaDB: Engine Independent Table Statistics, including histograms
 
New SQL features in latest MySQL releases
New SQL features in latest MySQL releasesNew SQL features in latest MySQL releases
New SQL features in latest MySQL releases
 
Efficient Pagination Using MySQL
Efficient Pagination Using MySQLEfficient Pagination Using MySQL
Efficient Pagination Using MySQL
 
MariaDB 10.0 Query Optimizer
MariaDB 10.0 Query OptimizerMariaDB 10.0 Query Optimizer
MariaDB 10.0 Query Optimizer
 
Window functions in MariaDB 10.2
Window functions in MariaDB 10.2Window functions in MariaDB 10.2
Window functions in MariaDB 10.2
 
MariaDB 10.3 Optimizer - where does it stand
MariaDB 10.3 Optimizer - where does it standMariaDB 10.3 Optimizer - where does it stand
MariaDB 10.3 Optimizer - where does it stand
 
Using Optimizer Hints to Improve MySQL Query Performance
Using Optimizer Hints to Improve MySQL Query PerformanceUsing Optimizer Hints to Improve MySQL Query Performance
Using Optimizer Hints to Improve MySQL Query Performance
 
M|18 Understanding the Query Optimizer
M|18 Understanding the Query OptimizerM|18 Understanding the Query Optimizer
M|18 Understanding the Query Optimizer
 
New features-in-mariadb-and-mysql-optimizers
New features-in-mariadb-and-mysql-optimizersNew features-in-mariadb-and-mysql-optimizers
New features-in-mariadb-and-mysql-optimizers
 
The MySQL Query Optimizer Explained Through Optimizer Trace
The MySQL Query Optimizer Explained Through Optimizer TraceThe MySQL Query Optimizer Explained Through Optimizer Trace
The MySQL Query Optimizer Explained Through Optimizer Trace
 
ANALYZE for executable statements - a new way to do optimizer troubleshooting...
ANALYZE for executable statements - a new way to do optimizer troubleshooting...ANALYZE for executable statements - a new way to do optimizer troubleshooting...
ANALYZE for executable statements - a new way to do optimizer troubleshooting...
 
Adapting to Adaptive Plans on 12c
Adapting to Adaptive Plans on 12cAdapting to Adaptive Plans on 12c
Adapting to Adaptive Plans on 12c
 
SQL Plan Directives explained
SQL Plan Directives explainedSQL Plan Directives explained
SQL Plan Directives explained
 

Similar to Optimizer features in recent releases of other databases

Performance improvements in PostgreSQL 9.5 and beyond
Performance improvements in PostgreSQL 9.5 and beyondPerformance improvements in PostgreSQL 9.5 and beyond
Performance improvements in PostgreSQL 9.5 and beyondTomas Vondra
 
Using PostgreSQL statistics to optimize performance
Using PostgreSQL statistics to optimize performance Using PostgreSQL statistics to optimize performance
Using PostgreSQL statistics to optimize performance Alexey Ermakov
 
03 2017Emea_RoadshowMilan-WhatsNew-Mariadbserver10_2andmaxscale 2_1
03 2017Emea_RoadshowMilan-WhatsNew-Mariadbserver10_2andmaxscale 2_103 2017Emea_RoadshowMilan-WhatsNew-Mariadbserver10_2andmaxscale 2_1
03 2017Emea_RoadshowMilan-WhatsNew-Mariadbserver10_2andmaxscale 2_1mlraviol
 
Introduction into MySQL Query Tuning
Introduction into MySQL Query TuningIntroduction into MySQL Query Tuning
Introduction into MySQL Query TuningSveta Smirnova
 
Improved histograms in MariaDB 10.8
Improved histograms in MariaDB 10.8Improved histograms in MariaDB 10.8
Improved histograms in MariaDB 10.8Sergey Petrunya
 
How Database Convergence Impacts the Coming Decades of Data Management
How Database Convergence Impacts the Coming Decades of Data ManagementHow Database Convergence Impacts the Coming Decades of Data Management
How Database Convergence Impacts the Coming Decades of Data ManagementSingleStore
 
Mysqlfunctions
MysqlfunctionsMysqlfunctions
MysqlfunctionsN13M
 
SQL Functions and Operators
SQL Functions and OperatorsSQL Functions and Operators
SQL Functions and OperatorsMohan Kumar.R
 
M|18 Taking Advantage of Common Table Expressions
M|18 Taking Advantage of Common Table ExpressionsM|18 Taking Advantage of Common Table Expressions
M|18 Taking Advantage of Common Table ExpressionsMariaDB plc
 
What's New in MariaDB Server 10.2 and MariaDB MaxScale 2.1
What's New in MariaDB Server 10.2 and MariaDB MaxScale 2.1What's New in MariaDB Server 10.2 and MariaDB MaxScale 2.1
What's New in MariaDB Server 10.2 and MariaDB MaxScale 2.1MariaDB plc
 
What's New in MariaDB Server 10.2 and MariaDB MaxScale 2.1
What's New in MariaDB Server 10.2 and MariaDB MaxScale 2.1What's New in MariaDB Server 10.2 and MariaDB MaxScale 2.1
What's New in MariaDB Server 10.2 and MariaDB MaxScale 2.1MariaDB plc
 
Linuxfest Northwest 2022 - MySQL 8.0 Nre Features
Linuxfest Northwest 2022 - MySQL 8.0 Nre FeaturesLinuxfest Northwest 2022 - MySQL 8.0 Nre Features
Linuxfest Northwest 2022 - MySQL 8.0 Nre FeaturesDave Stokes
 
MySQL 8.0 New Features -- September 27th presentation for Open Source Summit
MySQL 8.0 New Features -- September 27th presentation for Open Source SummitMySQL 8.0 New Features -- September 27th presentation for Open Source Summit
MySQL 8.0 New Features -- September 27th presentation for Open Source SummitDave Stokes
 
Performance Enhancements In Postgre Sql 8.4
Performance Enhancements In Postgre Sql 8.4Performance Enhancements In Postgre Sql 8.4
Performance Enhancements In Postgre Sql 8.4HighLoad2009
 
PostgreSQL query planner's internals
PostgreSQL query planner's internalsPostgreSQL query planner's internals
PostgreSQL query planner's internalsAlexey Ermakov
 
MySQL Query tuning 101
MySQL Query tuning 101MySQL Query tuning 101
MySQL Query tuning 101Sveta Smirnova
 
Row Pattern Matching in Oracle Database 12c
Row Pattern Matching in Oracle Database 12cRow Pattern Matching in Oracle Database 12c
Row Pattern Matching in Oracle Database 12cStew Ashton
 
Myth busters - performance tuning 101 2007
Myth busters - performance tuning 101 2007Myth busters - performance tuning 101 2007
Myth busters - performance tuning 101 2007paulguerin
 
Mysql alter-command
Mysql alter-commandMysql alter-command
Mysql alter-commandbeben benzy
 

Similar to Optimizer features in recent releases of other databases (20)

Performance improvements in PostgreSQL 9.5 and beyond
Performance improvements in PostgreSQL 9.5 and beyondPerformance improvements in PostgreSQL 9.5 and beyond
Performance improvements in PostgreSQL 9.5 and beyond
 
Using PostgreSQL statistics to optimize performance
Using PostgreSQL statistics to optimize performance Using PostgreSQL statistics to optimize performance
Using PostgreSQL statistics to optimize performance
 
03 2017Emea_RoadshowMilan-WhatsNew-Mariadbserver10_2andmaxscale 2_1
03 2017Emea_RoadshowMilan-WhatsNew-Mariadbserver10_2andmaxscale 2_103 2017Emea_RoadshowMilan-WhatsNew-Mariadbserver10_2andmaxscale 2_1
03 2017Emea_RoadshowMilan-WhatsNew-Mariadbserver10_2andmaxscale 2_1
 
Introduction into MySQL Query Tuning
Introduction into MySQL Query TuningIntroduction into MySQL Query Tuning
Introduction into MySQL Query Tuning
 
Improved histograms in MariaDB 10.8
Improved histograms in MariaDB 10.8Improved histograms in MariaDB 10.8
Improved histograms in MariaDB 10.8
 
How Database Convergence Impacts the Coming Decades of Data Management
How Database Convergence Impacts the Coming Decades of Data ManagementHow Database Convergence Impacts the Coming Decades of Data Management
How Database Convergence Impacts the Coming Decades of Data Management
 
Mysqlfunctions
MysqlfunctionsMysqlfunctions
Mysqlfunctions
 
SQL Functions and Operators
SQL Functions and OperatorsSQL Functions and Operators
SQL Functions and Operators
 
M|18 Taking Advantage of Common Table Expressions
M|18 Taking Advantage of Common Table ExpressionsM|18 Taking Advantage of Common Table Expressions
M|18 Taking Advantage of Common Table Expressions
 
What's New in MariaDB Server 10.2 and MariaDB MaxScale 2.1
What's New in MariaDB Server 10.2 and MariaDB MaxScale 2.1What's New in MariaDB Server 10.2 and MariaDB MaxScale 2.1
What's New in MariaDB Server 10.2 and MariaDB MaxScale 2.1
 
What's New in MariaDB Server 10.2 and MariaDB MaxScale 2.1
What's New in MariaDB Server 10.2 and MariaDB MaxScale 2.1What's New in MariaDB Server 10.2 and MariaDB MaxScale 2.1
What's New in MariaDB Server 10.2 and MariaDB MaxScale 2.1
 
Linuxfest Northwest 2022 - MySQL 8.0 Nre Features
Linuxfest Northwest 2022 - MySQL 8.0 Nre FeaturesLinuxfest Northwest 2022 - MySQL 8.0 Nre Features
Linuxfest Northwest 2022 - MySQL 8.0 Nre Features
 
MySQL 8.0 New Features -- September 27th presentation for Open Source Summit
MySQL 8.0 New Features -- September 27th presentation for Open Source SummitMySQL 8.0 New Features -- September 27th presentation for Open Source Summit
MySQL 8.0 New Features -- September 27th presentation for Open Source Summit
 
Dun ddd
Dun dddDun ddd
Dun ddd
 
Performance Enhancements In Postgre Sql 8.4
Performance Enhancements In Postgre Sql 8.4Performance Enhancements In Postgre Sql 8.4
Performance Enhancements In Postgre Sql 8.4
 
PostgreSQL query planner's internals
PostgreSQL query planner's internalsPostgreSQL query planner's internals
PostgreSQL query planner's internals
 
MySQL Query tuning 101
MySQL Query tuning 101MySQL Query tuning 101
MySQL Query tuning 101
 
Row Pattern Matching in Oracle Database 12c
Row Pattern Matching in Oracle Database 12cRow Pattern Matching in Oracle Database 12c
Row Pattern Matching in Oracle Database 12c
 
Myth busters - performance tuning 101 2007
Myth busters - performance tuning 101 2007Myth busters - performance tuning 101 2007
Myth busters - performance tuning 101 2007
 
Mysql alter-command
Mysql alter-commandMysql alter-command
Mysql alter-command
 

More from Sergey Petrunya

New optimizer features in MariaDB releases before 10.12
New optimizer features in MariaDB releases before 10.12New optimizer features in MariaDB releases before 10.12
New optimizer features in MariaDB releases before 10.12Sergey Petrunya
 
MariaDB's join optimizer: how it works and current fixes
MariaDB's join optimizer: how it works and current fixesMariaDB's join optimizer: how it works and current fixes
MariaDB's join optimizer: how it works and current fixesSergey Petrunya
 
JSON Support in MariaDB: News, non-news and the bigger picture
JSON Support in MariaDB: News, non-news and the bigger pictureJSON Support in MariaDB: News, non-news and the bigger picture
JSON Support in MariaDB: News, non-news and the bigger pictureSergey Petrunya
 
MariaDB 10.4 - что нового
MariaDB 10.4 - что новогоMariaDB 10.4 - что нового
MariaDB 10.4 - что новогоSergey Petrunya
 
MyRocks in MariaDB | M18
MyRocks in MariaDB | M18MyRocks in MariaDB | M18
MyRocks in MariaDB | M18Sergey Petrunya
 
New Query Optimizer features in MariaDB 10.3
New Query Optimizer features in MariaDB 10.3New Query Optimizer features in MariaDB 10.3
New Query Optimizer features in MariaDB 10.3Sergey Petrunya
 
MyRocks in MariaDB: why and how
MyRocks in MariaDB: why and howMyRocks in MariaDB: why and how
MyRocks in MariaDB: why and howSergey Petrunya
 
Эволюция репликации в MySQL и MariaDB
Эволюция репликации в MySQL и MariaDBЭволюция репликации в MySQL и MariaDB
Эволюция репликации в MySQL и MariaDBSergey Petrunya
 
MariaDB 10.1 - что нового.
MariaDB 10.1 - что нового.MariaDB 10.1 - что нового.
MariaDB 10.1 - что нового.Sergey Petrunya
 
MyRocks: табличный движок для MySQL на основе RocksDB
MyRocks: табличный движок для MySQL на основе RocksDBMyRocks: табличный движок для MySQL на основе RocksDB
MyRocks: табличный движок для MySQL на основе RocksDBSergey Petrunya
 
MariaDB: ANALYZE for statements (lightning talk)
MariaDB:  ANALYZE for statements (lightning talk)MariaDB:  ANALYZE for statements (lightning talk)
MariaDB: ANALYZE for statements (lightning talk)Sergey Petrunya
 
How mysql handles ORDER BY, GROUP BY, and DISTINCT
How mysql handles ORDER BY, GROUP BY, and DISTINCTHow mysql handles ORDER BY, GROUP BY, and DISTINCT
How mysql handles ORDER BY, GROUP BY, and DISTINCTSergey Petrunya
 

More from Sergey Petrunya (14)

New optimizer features in MariaDB releases before 10.12
New optimizer features in MariaDB releases before 10.12New optimizer features in MariaDB releases before 10.12
New optimizer features in MariaDB releases before 10.12
 
MariaDB's join optimizer: how it works and current fixes
MariaDB's join optimizer: how it works and current fixesMariaDB's join optimizer: how it works and current fixes
MariaDB's join optimizer: how it works and current fixes
 
JSON Support in MariaDB: News, non-news and the bigger picture
JSON Support in MariaDB: News, non-news and the bigger pictureJSON Support in MariaDB: News, non-news and the bigger picture
JSON Support in MariaDB: News, non-news and the bigger picture
 
MariaDB 10.4 - что нового
MariaDB 10.4 - что новогоMariaDB 10.4 - что нового
MariaDB 10.4 - что нового
 
MyRocks in MariaDB | M18
MyRocks in MariaDB | M18MyRocks in MariaDB | M18
MyRocks in MariaDB | M18
 
New Query Optimizer features in MariaDB 10.3
New Query Optimizer features in MariaDB 10.3New Query Optimizer features in MariaDB 10.3
New Query Optimizer features in MariaDB 10.3
 
MyRocks in MariaDB
MyRocks in MariaDBMyRocks in MariaDB
MyRocks in MariaDB
 
Say Hello to MyRocks
Say Hello to MyRocksSay Hello to MyRocks
Say Hello to MyRocks
 
MyRocks in MariaDB: why and how
MyRocks in MariaDB: why and howMyRocks in MariaDB: why and how
MyRocks in MariaDB: why and how
 
Эволюция репликации в MySQL и MariaDB
Эволюция репликации в MySQL и MariaDBЭволюция репликации в MySQL и MariaDB
Эволюция репликации в MySQL и MariaDB
 
MariaDB 10.1 - что нового.
MariaDB 10.1 - что нового.MariaDB 10.1 - что нового.
MariaDB 10.1 - что нового.
 
MyRocks: табличный движок для MySQL на основе RocksDB
MyRocks: табличный движок для MySQL на основе RocksDBMyRocks: табличный движок для MySQL на основе RocksDB
MyRocks: табличный движок для MySQL на основе RocksDB
 
MariaDB: ANALYZE for statements (lightning talk)
MariaDB:  ANALYZE for statements (lightning talk)MariaDB:  ANALYZE for statements (lightning talk)
MariaDB: ANALYZE for statements (lightning talk)
 
How mysql handles ORDER BY, GROUP BY, and DISTINCT
How mysql handles ORDER BY, GROUP BY, and DISTINCTHow mysql handles ORDER BY, GROUP BY, and DISTINCT
How mysql handles ORDER BY, GROUP BY, and DISTINCT
 

Recently uploaded

How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsAndolasoft Inc
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionSolGuruz
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdfPearlKirahMaeRagusta1
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...panagenda
 
How to Choose the Right Laravel Development Partner in New York City_compress...
How to Choose the Right Laravel Development Partner in New York City_compress...How to Choose the Right Laravel Development Partner in New York City_compress...
How to Choose the Right Laravel Development Partner in New York City_compress...software pro Development
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
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-...Steffen Staab
 
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 2024Mind IT Systems
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
 
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 studentsHimanshiGarg82
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplatePresentation.STUDIO
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...Health
 
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.pdfproinshot.com
 
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.pdfVishalKumarJha10
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
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.pdfkalichargn70th171
 
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) SolutionOnePlan Solutions
 
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...kalichargn70th171
 

Recently uploaded (20)

How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdf
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
How to Choose the Right Laravel Development Partner in New York City_compress...
How to Choose the Right Laravel Development Partner in New York City_compress...How to Choose the Right Laravel Development Partner in New York City_compress...
How to Choose the Right Laravel Development Partner in New York City_compress...
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
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-...
 
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
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
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
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
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
 
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
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
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
 
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
 
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
 

Optimizer features in recent releases of other databases

  • 1. [some] Optimizer features in recent releases of other databases Sergei Petrunia Barcelona ACM October 2019
  • 3. MySQL 8.0 MySQL 8.0.n - Iterator-based Executor (introduced gradually) MySQL 8.0.13 (2018-10-22, GA) - Skip Scan (contribution from Facebook) MySQL 8.0.14 (2019-01-21, GA) - LATERAL support MySQL 8.0.17 (2019-07-22, GA) - Multi-valued indexes for JSON - NOT IN/EXISTS/.. -> anti-join - EXISTS -> Semi-join conversion - [Anti-]semi-join conversion IS TRUE/IS NULL - Semi-join optimization for subqueries in the ON expressions MySQL 8.0.18 (2019-10-14, GA) - Hash join - EXPLAIN ANALYZE
  • 4. Iterator-based executor ● The idea: switch server internals to the init()/get_next() interface – Unifies all access methods (quick selects, full scans, NL-joins, etc) – A textbook-like approach, similar to PostgreSQL – Pay-offs? ● Cursors ● Flexibility allows further development ● New EXPLAIN form, EXPLAIN FORMAT=TREE ● Doesn’t handle all SQL features yet – Handles semi-join subqueries – Doesn’t handle outer joins. – Doesn’t handle certain kinds of non-indexed joins?
  • 5. EXPLAIN ANALYZE ● Overlapping functionality with MariaDB’s ANALYZE (since 10.1) ● Only works with Iterator-based executor ● Doesn’t [yet] work with – SELECT queries not using the iterator-based executor ● LEFT JOINs ● ... – UPDATE/DELETE/etc
  • 6. ANALYZE in MariaDB select * from ten, t1, t2 where ten.col1 < 7 and t1.key1=ten.a and t2.key1=t1.a +------+-------------+-------+------+---------------+------+---------+-----------+------+--------+----------+------------+----------- | id   | select_type | table | type | possible_keys | key  | key_len | ref       | rows | r_rows | filtered | r_filtered | Extra      +------+-------------+-------+------+---------------+------+---------+-----------+------+--------+----------+------------+----------- |    1 | SIMPLE      | ten   | ALL  | PRIMARY       | NULL | NULL    | NULL      | 10   | 10.00  |   100.00 |      70.00 | Using wher |    1 | SIMPLE      | t1    | ref  | key1          | key1 | 5       | j20.ten.a | 1    | 2.86   |   100.00 |     100.00 | Using wher |    1 | SIMPLE      | t2    | ref  | key1          | key1 | 5       | j20.t1.a  | 1    | 10.00  |   100.00 |     100.00 |            +------+-------------+-------+------+---------------+------+---------+-----------+------+--------+----------+------------+-----------
  • 7. EXPLAIN ANALYZE select * from ten, t1, t2 where ten.col1 < 7 and t1.key1=ten.a and t2.key1=t1.a -> Nested loop inner join (cost=3.58 rows=3) (actual time=0.882..18.963 rows=200 loops=1) -> Nested loop inner join (cost=2.42 rows=3) (actual time=0.648..3.992 rows=20 loops=1) -> Filter: (ten.col1 < 7) (cost=1.25 rows=3) (actual time=0.303..0.433 rows=7 loops=1) -> Table scan on ten (cost=1.25 rows=10) (actual time=0.296..0.394 rows=10 loops=1) -> Filter: (t1.a is not null) (cost=0.28 rows=1) (actual time=0.178..0.504 rows=3 loops=7) -> Index lookup on t1 using key1 (key1=ten.a) (cost=0.28 rows=1) (actual time=0.176..0.497 rows=3 loops=7) -> Index lookup on t2 using key1 (key1=t1.a) (cost=0.28 rows=1) (actual time=0.155..0.735 rows=10 loops=20)
  • 8. EXPLAIN ANALYZE select * from ten, t1, t2 where ten.col1 < 7 and t1.key1=ten.a and t2.key1=t1.a -> Nested loop inner join (cost=3.58 rows=3) (actual time=0.882..18.963 rows=200 loops=1) -> Nested loop inner join (cost=2.42 rows=3) (actual time=0.648..3.992 rows=20 loops=1) -> Filter: (ten.col1 < 7) (cost=1.25 rows=3) (actual time=0.303..0.433 rows=7 loops=1) -> Table scan on ten (cost=1.25 rows=10) (actual time=0.296..0.394 rows=10 loops=1) -> Filter: (t1.a is not null) (cost=0.28 rows=1) (actual time=0.178..0.504 rows=3 loops=7) -> Index lookup on t1 using key1 (key1=ten.a) (cost=0.28 rows=1) (actual time=0.176..0.497 rows=3 loops=7) -> Index lookup on t2 using key1 (key1=t1.a) (cost=0.28 rows=1) (actual time=0.155..0.735 rows=10 loops=20)
  • 9. EXPLAIN ANALYZE select * from ten, t1, t2 where ten.col1 < 7 and t1.key1=ten.a and t2.key1=t1.a -> Nested loop inner join (cost=3.58 rows=3) (actual time=0.882..18.963 rows=200 loops=1) -> Nested loop inner join (cost=2.42 rows=3) (actual time=0.648..3.992 rows=20 loops=1) -> Filter: (ten.col1 < 7) (cost=1.25 rows=3) (actual time=0.303..0.433 rows=7 loops=1) -> Table scan on ten (cost=1.25 rows=10) (actual time=0.296..0.394 rows=10 loops=1) -> Filter: (t1.a is not null) (cost=0.28 rows=1) (actual time=0.178..0.504 rows=3 loops=7) -> Index lookup on t1 using key1 (key1=ten.a) (cost=0.28 rows=1) (actual time=0.176..0.497 rows=3 loops=7) -> Index lookup on t2 using key1 (key1=t1.a) (cost=0.28 rows=1) (actual time=0.155..0.735 rows=10 loops=20) (actual time=0.176..0.497 rows=3 loops=7)
  • 10. Convert NOT IN/EXISTS to anti-join ● Before: subquery predicate attached as early as possible – Subquery execution short-cuts as soon as match is found ● Now: anti-join operation – Participates in join optimization (possiblity for better plans?) – Potentially, could benefit from join algorithms (BKA, hash join, etc) ● Not sure if it actually does
  • 11. Convert EXISTS(...) to semi-join ● MariaDB: similar feature in 10.0, “EXISTS->IN conversion” – Trivial correlation detection/removal works in both – But MariaDB’s EXISTS->IN works for non-semi-joins, too.
  • 12. Hash Join ● It’s a “Grace Hash Join” (correction by Igor: not quite!) – Theoretically should be better than “BNL-H” we have ● One read pass, hash table spills over to disk ● It uses the “iterator interface” – Doesn’t support certain SQL features ● Left join, etc.. – Supports semi-join ● Need to study this further
  • 14. PostgreSQL, relevant features in recent versions PostgreSQL 11, 2018-10-18 ● Improved partitioning ● Improved query parallelism ● Parallel index creation ● JIT compilation for expressions PostgreSQL 12, 2019-10-03 ● Non-recursive CTEs are now inlined ● MCV statistics for multiple columns ● JSONPath (but not indexing) ● llvm JIT is enabled by default if compiled-in PostgreSQL 9.6, 2016-09-29 ● Parallel query support PostgreSQL 10, 2017-10-05 ● Logical replication ● Improved query parallelism ● Multi-column statistics: correlation ratio, #distinct_values
  • 15. Inlining non-recursive CTEs ● Before PostgreSQL 12: CTE is materialized and is an “optimization barrier”
  • 16. 19 CTE Merge Condition pushdown CTE reuse MariaDB 10.2 ✔ ✔ ✘ MS SQL Server ✔ ✔ ✘ PostgreSQL ✘ ✘ ✔ MySQL 8.0.0 ✔ ✘ ✔ CTE Optimizations summary  Merge and condition pushdown are most important  MariaDB supports them, like MS SQL.  PostgreSQL’s approach is *weird*  “CTEs are optimization barriers”  MySQL: “try merging, otherwise reuse” Q uoting m y slide from M |18: Fixed in PostgreSQL 12
  • 17. MCV statistics for multiple columns select * from cars_for_sale where maker='Honda' and model='Civic' select * from users where city='Moscow' and country='Russia|USA' ● Issue: correlated conditions in WHERE CREATE STATISTICS s2 (mcv) ON col1, col2 FROM t2; ANALYZE TABLE t2; ● Assuming independence and multipying selectivities is bad – Bruce Momjan(?): “90% of complaints about the optimizer are about this” ● Solution: Most-Common-Values statistics for multiple columns: ● Note: the statistics (s2) is present is [auto-]recomputed – There’s DROP STATISTICS to remove it
  • 18. Parallel index creation (PostgreSQL 11) ● Use multiple threads when creating an index – a typical objection “does this help for an IO-bound workload”? workers speedup 1 1.00 2 2.32 4 2.87 8 3.33 ● Experiment results: it depends – col1 INT, key(col1) - less speedup (~1.5 x) – 3-keypart key: up 3.33x speedup ● Machine – intel i9, 8 cores/16 threads – Intel Optane SSD 900P (~1K eur)
  • 19. Parallel query execution ● Supports joins and aggregation – Parallel table scan – Aggregate functions – Parallel join algoritms ● Many constructs are “parallel stoppers” – CTEs ● This is why my TPC-DS benchmark run didn’t benefit from parallel – ... – TPC-H will show more speedups