Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

How to Take Advantage of Optimizer Improvements in MySQL 8.0

672 views

Published on

MySQL 8.0 introduces several improvements to the query optimizer that may give improved performance for your queries. This presentation looks at what kind of queries the different improvements apply to, and the focus is on what you can do to get the most out of the optimizer improvements. The main topics are changes to the optimizer cost model, histograms, and new optimizer hints, but other improvements to how MySQL executes queries are also covered. The presentation includes many practical examples of how you can get a significant speedup for your MySQL queries.

Published in: Data & Analytics
  • Be the first to comment

How to Take Advantage of Optimizer Improvements in MySQL 8.0

  1. 1. Copyright © 2018 Oracle and/or its afliates. All rights reserved. How to Take Advantage of Optiiier Iiproveients in MySQL 8.0 Norvald H. Ryeng Sofware Developient Senior Manager MySQL Optiiier Teai October, 2018
  2. 2. 3Copyright © 2018 Oracle and/or its afliates. All rights reserved. Safe Harbor Stateient The following is intended to outline our general product directon. It is intended for inforiaton purposes only, and iay not be incorporated into any contract. It is not a coiiitient to deliver any iaterial, code, or functonality, and should not be relied upon in iaking purchasing decisions. The developient, release, and tiing of any features or functonality described for Oracle’s products reiains at the sole discreton of Oracle.
  3. 3. 4Copyright © 2018 Oracle and/or its afliates. All rights reserved. Prograi Agenda Cost iodel iiproveients Histograis Optiiier hints Iiproved perforiance with CTEs Iiproveients in query executon 1 2 3 4 5 6 7
  4. 4. 6Copyright © 2018 Oracle and/or its afliates. All rights reserved. Cost Model Iiproveients
  5. 5. 7Copyright © 2018 Oracle and/or its afliates. All rights reserved. Optiiier Cost Model t1 Cost estiate Row estiate Cost Model Cost foriulas Access iethods Join Subquery Cost constants CPU IO Metadata: - Row and index siie - Index inforiaton - Uniqueness Statstcs: - Table siie - Cardinality - Range estiates Cost iodel configuraton Range scan JOIN New in MySQL 5.7
  6. 6. 8Copyright © 2018 Oracle and/or its afliates. All rights reserved. Motvaton for Iiproving the MySQL Cost Model ● Produce iore correct cost estiates – Beter decisions by the optiiier should iiprove perforiance ● Adapt to new hardware architectures – SSD, larger ieiories, caches ● More iaintainable cost iodel iipleientaton – Avoid hard coded “cost constants” – Refactoring of existng cost iodel code ● Configurable and tunable ● Make iore of the optiiier cost-based Faster queries
  7. 7. 9Copyright © 2018 Oracle and/or its afliates. All rights reserved. New Storage Technologies ● Tiie to do a table scan of 10 iillion records: ● Adjust cost iodel to support diferent storage technologies ● Provide configurable cost constants for diferent storage technologies Meiory 5 s SSD 20 - 146 s Hard disk 32 - 1465 s Provide a prograi that could ieasure perforiance and suggest good cost constant configuraton for a running MySQL server? Provide a prograi that could ieasure perforiance and suggest good cost constant configuraton for a running MySQL server?
  8. 8. 10Copyright © 2018 Oracle and/or its afliates. All rights reserved. Meiory Bufer Aware Cost Estiates ● Storage engines: – Estiate for how iuch of data and indexes are in a ieiory bufer – Estiate for hit rate for ieiory bufer ● Optiiier cost iodel: – Take into account whether data is already in ieiory or need to be read froi disk Server Storage engine Disk data Query executor Database bufer
  9. 9. 11Copyright © 2018 Oracle and/or its afliates. All rights reserved. Disk vs. Meiory Access ● New defaults for const constants: ● InnoDB reports percentage of data cached in bufer pool for each table/index ● Note: Query plan iay change between executons Cost MySQL 5.7 MySQL 8.0 Read a randoi disk page 1.0 1.0 Read a data page froi ieiory bufer 1.0 0.25 Evaluate query conditon 0.2 0.1 Coipare keys/rows 0.1 0.05 Saie cost constant
  10. 10. 12Copyright © 2018 Oracle and/or its afliates. All rights reserved. DBT-3 Query 8 Natoonal market share SELECT o_year, SUM(CASE WHEN naton = 'FRANCE' THEN volume ELSE 0 END) / SUM(volume) AS mkt_share FROM ( SELECT EXTRACT(YEAR FROM o_orderdate) AS o_year, l_extendedprice * (1 - l_discount) AS volume, n2.n_name AS naton FROM part JOIN lineitem ON p_partkey = l_partkey JOIN supplier ON s_suppkey = l_suppkey JOIN orders ON l_orderkey = o_orderkey JOIN customer ON o_custkey = c_custkey JOIN naton n1 ON c_natonkey = n1.n_natonkey JOIN region ON n1.n_regionkey = r_regionkey JOIN naton n2 ON s_natonkey = n2.n_natonkey WHERE r_name = 'EUROPE' AND o_orderdate BETWEEN '1995-01-01' AND '1996-12-31' AND p_type = 'PROMO BRUSHED STEEL' ) AS all_natons GROUP BY o_year ORDER BY o_year; High selectvity predicate
  11. 11. 13Copyright © 2018 Oracle and/or its afliates. All rights reserved. Plan A Plan B DBT-3 Query 8 Alteronatve query plaons
  12. 12. 14Copyright © 2018 Oracle and/or its afliates. All rights reserved. DBT-3 Query 8 Executoon tme (8.0.3) Ion-memory Disk-bouond Plaon A 5.8 secs 9 iin 47 secs Plaon B 77.5 secs 3 mion 49 secs Ion-memory Disk-bouond MySQL 5.6 Plan B MySQL 5.7 Plan A MySQL 8.0 Plan A Plan B Selected plaon
  13. 13. 15Copyright © 2018 Oracle and/or its afliates. All rights reserved. How to Configure your Own Cost Constants UPDATE mysql.engine_cost SET cost_value=0.1 WHERE cost_name='memory_block_read_cost'; FLUSH OPTIMIZER_COSTS; Note: ● Only new connectons will see updated cost constants Future ideas: ● Create tool to tune cost constants to specific hardware ● Use iachine learning to find optial values for specific user load Default 0.25 Make optiiier read new cost constants
  14. 14. 16Copyright © 2018 Oracle and/or its afliates. All rights reserved. Histograis
  15. 15. 17Copyright © 2018 Oracle and/or its afliates. All rights reserved. Histograis ● Provides the optiiier with inforiaton about coluin value distributon ● To create/recalculate histograi for a coluin: ANALYZE TABLE table UPDATE HISTOGRAM ON column WITH n BUCKETS; ● May use saipling – Saiple siie is based on available ieiory (histograi_generaton_iax_iei_siie) ● Autoiatcally chooses between two histograi types: – Singleton: One value per bucket – Equi-height: Multple values per bucket – Max 1024 buckets
  16. 16. 18Copyright © 2018 Oracle and/or its afliates. All rights reserved. Histograis Exaiple EXPLAIN SELECT * FROM customer JOIN orders ON c_custkey = o_custkey WHERE c_acctbal < -1000 AND o_orderdate < '1993-01-01'; id select type table type possible keys key key leon ref rows fltered extra 1 SIMPLE orders ALL i_o_orderdate, i_o_custkey NULL NULL NULL 15000000 31.19 Using where 1 SIMPLE custoier eq_ref PRIMARY PRIMARY 4 dbt3.orders. o_custkey 1 33.33 Using where
  17. 17. 19Copyright © 2018 Oracle and/or its afliates. All rights reserved. Histograis Exaiple ANALYZE TABLE customer UPDATE HISTOGRAM ON c_acctbal WITH 1024 BUCKETS; EXPLAIN SELECT * FROM customer JOIN orders ON c_custkey = o_custkey WHERE c_acctbal < -1000 AND o_orderdate < '1993-01-01'; id select type table type possible keys key key leon ref rows fltered extra 1 SIMPLE custoier ALL PRIMARY NULL NULL NULL 1500000 0.00 Using where 1 SIMPLE orders ref i_o_orderdate, i_o_custkey i_o_custkey 5 dbt3. custoier. c_custkey 1 31.19 Using where
  18. 18. 20Copyright © 2018 Oracle and/or its afliates. All rights reserved. Histograis Exaiple 0 2 4 6 8 10 12 14 16 orders → custoier custoier → orders QueryExecutoonTime(secoonds)
  19. 19. 21Copyright © 2018 Oracle and/or its afliates. All rights reserved. Singleton Histograi ● One value per bucket ● Each bucket stores: – Value – Cuiulatve frequency ● Well suited to estiate both equality and range predicates 0 1 2 3 5 6 7 8 9 10 0 0.05 0.1 0.15 0.2 0.25 Frequeoncy
  20. 20. 22Copyright © 2018 Oracle and/or its afliates. All rights reserved. Equi-Height Histograi ● Multple values per bucket ● Not quite equi-height – Values are not split across buckets – Frequent values in separate buckets ● Each bucket stores: – Miniiui value – Maxiiui value – Cuiulatve frequency – Nuiber of distnct values ● Best suited for range predicates 0 - 0 1 - 1 2 - 3 5 - 6 7 - 10 0 0.05 0.1 0.15 0.2 0.25 0.3 0.35 Frequeoncy
  21. 21. 23Copyright © 2018 Oracle and/or its afliates. All rights reserved. Usage ● Create or refresh histograi(s) for coluin(s): ANALYZE TABLE table UPDATE HISTOGRAM ON column [, column] WITH n BUCKETS; – Note: Will only update histograi, not other statstcs ● Drop histograi: ANALYZE TABLE table DROP HISTOGRAM ON column [, column]; ● Based on entre table or saipling: – Depends on available ieiory: histogram_geoneratoon_max_mem_size (default: 20 MB) ● New storage engine API for saipling – Default iipleientaton: Full table scan even when saipling – Storage engines iay iipleient iore efcient saipling
  22. 22. 24Copyright © 2018 Oracle and/or its afliates. All rights reserved. Storage ● Stored in a JSON coluin in data dictonary ● Can be inspected in Inforiaton Scheia view SELECT JSON_PRETTY(histogram) FROM informaton_schema.column_statstcs WHERE schema_name = 'dbt3_sf1' AND table_name ='lineitei' AND column_name = 'l_linenuiber';
  23. 23. 25Copyright © 2018 Oracle and/or its afliates. All rights reserved. Histograi Content { "buckets": [[1, 0.24994938524948698], [2, 0.46421066400720523], [3, 0.6427401784471978], [4, 0.7855470933802572], [5, 0.8927398868395817], [6, 0.96423707532558], [7, 1] ], "data-type": "int", "null-values": 0.0, "collaton-id": 8, "last-updated": "2018-02-03 21:05:21.690872", "saipling-rate": 0.20829115437457252, "histograi-type": "singleton", "nuiber-of-buckets-specified": 1024 }
  24. 24. 27Copyright © 2018 Oracle and/or its afliates. All rights reserved. When to Create Histograis ● Histograis are useful for coluins that are – Not the first coluin of any index, and – Used in WHERE conditons of ● JOIN queries ● Queries with IN subqueries ● ORDER BY … LIMIT queries ● Best fit – Low cardinality coluins (e.g., gender, orderStatus, dayOfWeek, enuis) – Coluins with uneven distributon (skew) – Stable distributon over tie
  25. 25. 28Copyright © 2018 Oracle and/or its afliates. All rights reserved. When Not to Create Histograis ● First coluin of an index ● Coluin that is never used in WHERE clauses ● Monotonically increasing coluin values (e.g., tiestaips) – Histograis will need frequent updates – Consider creatng and index instead
  26. 26. 29Copyright © 2018 Oracle and/or its afliates. All rights reserved. How Many Buckets? ● If possible, enough to create a singleton histograi ● Equi-height: 100 buckets should be enough – 1 % resoluton
  27. 27. 30Copyright © 2018 Oracle and/or its afliates. All rights reserved. Optiiier Hints
  28. 28. 31Copyright © 2018 Oracle and/or its afliates. All rights reserved. New Optiiier Hints in 8.0 ● Join order – JOIN_ORDER(tables) – JOIN_PREFIX(tables) – JOIN_SUFFIX(tables) – JOIN_FIXED_ORDER() ● Setng systei variables – SET_VAR(sysvar=value) ● View/derived table/CTE ierge – MERGE(views) – NO_MERGE(views) ● Index ierge – INDEX_MERGE(indexes) – NO_INDEX_MERGE(indexes)
  29. 29. 32Copyright © 2018 Oracle and/or its afliates. All rights reserved. Join Order Hints ● No need to reorganiie the FROM clause to add join order hints like you will for STRAIGHT_JOIN ● /*+ JOIN_ORDER(t1, t2, …) */ ● /*+ JOIN_PREFIX(t1, t2, …) */ ● /*+ JOIN_SUFFIX(…, ty, tz) */ ● /*+ JOIN_FIXED_ORDER() */ – Replaceient for STRAIGHT_JOIN
  30. 30. 33Copyright © 2018 Oracle and/or its afliates. All rights reserved. Join Order Hint Exaiple EXPLAIN SELECT /*+ JOIN_ORDER(customer, orders) */ * FROM customer JOIN orders ON c_custkey = o_custkey WHERE c_acctbal < -1000 AND o_orderdate < '1993-01-01'; Alternatves with saie efect for this query: JOIN_PREFIX(customer) JOIN_SUFFIX(orders) JOIN_FIXED_ORDER() id select type table type possible keys key key leon ref rows fltered extra 1 SIMPLE custoier ALL PRIMARY NULL NULL NULL 1500000 33.33 Using where 1 SIMPLE orders ref i_o_orderdate, i_o_custkey i_o_custkey 5 dbt3. custoier. c_custkey 15 31.19 Using where
  31. 31. 35Copyright © 2018 Oracle and/or its afliates. All rights reserved. View/Derived Table/CTE Merge Hints ● Views, derived tables and CTEs are, if possible, ierged into outer query ● NO_MERGE can override default behavior SELECT /*+ NO_MERGE(dt) */ * FROM t1 JOIN (SELECT x, y FROM t2) dt ON t1.x = dt.x; ● MERGE will force a ierge SELECT /*+ MERGE(dt) */ * FROM t1 JOIN (SELECT x, y FROM t2) dt ON t1.x = dt.x; ● Can also use MERGE/NO_MERGE hints for views and CTEs SELECT /*+ NO_MERGE(v) */ * FROM t1 JOIN v ON t1.x = v.x;
  32. 32. 36Copyright © 2018 Oracle and/or its afliates. All rights reserved. Index Merge Exaiple 10INDEX(a) 10INDEX(b) a=10 AND b=10Result: Intersecton SELECT * FROM t1 WHERE a=10 AND b=10
  33. 33. 37Copyright © 2018 Oracle and/or its afliates. All rights reserved. Index Merge Hints ● Index ierge: Merge rows froi iultple range scans on a single table ● Algorithis: union, intersecton, sort union ● Users can specify which indexes to use for index ierge – /*+ INDEX_MERGE(t1 idx1, idx2, …) */ – /*+ NO_INDEX_MERGE(t1 idx1, idx2, …) */
  34. 34. 38Copyright © 2018 Oracle and/or its afliates. All rights reserved. Index Merge Hint Exaiple EXPLAIN SELECT count(*) FROM users WHERE user_type=2 AND status=0 AND pareont_id=0; mysql> SELECT count(*) FROM users WHERE user_type=2 AND status=0 AND parent_id=0; ... 1 row in set (1.37 sec) mysql> SELECT /*+ INDEX_MERGE(users user_type, status) */ count(*) -> FROM users WHERE user_type=2 AND status=0 AND parent_id=0; ... 1 row in set (0.18 sec) id select type table type possible keys key key leon ref rows Extra 1 SIMPLE users index_ ierge parent_id, status, user_type user_type, status, parent_id 1,1,4 NULL 2511 Using intersect (user_type, status, parent_id); Using where; Using index Low selectvity predicate
  35. 35. 39Copyright © 2018 Oracle and/or its afliates. All rights reserved. Hints to Set Session Variables ● Set a session variable for the duraton of a single stateient ● Exaiples: SELECT /*+ SET_VAR(sort_bufer_size = 16M) */ naie FROM people ORDER BY naie; INSERT /*+ SET_VAR(foreigon_key_checks = OFF) */ INTO t2 VALUES (1, 1), (2, 2), (3, 3); SELECT /*+ SET_VAR(optmizer_switch = 'coonditoon_faonout_flter = of') */ * FROM custoier JOIN orders ON c_custkey = o_custkey WHERE c_acctbal < 0 AND o_orderdate < '1993-01-01'; ● Note: Not all session variables are setable through hints: iysql> SELECT /*+ SET_VAR(max_allowed_packet=128M) */ * FROM t1; Eipty set, 1 warning (0,00 sec) Warning (Code 4537): Variable 'iax_allowed_packet' cannot be set using SET_VAR hint.
  36. 36. 40Copyright © 2018 Oracle and/or its afliates. All rights reserved. Skip Index Dives for FORCE INDEX Hint ● Estiate nuiber of rows in a range – The optiiier asks the storage engine for nuiber of rows to be scanned froi an index – Index dives: InnoDB finds first and last row in range and estiates distance – Exaiple: SELECT * FROM t1 WHERE (key1 > 10 AND key1 < 20) AND key2 > 30 Indexes on key1 and key2 will be used to get estiates for the two ranges ● MySQL 8.0 will skip index dives when all of these are satsfied: – FORCE INDEX applies to a single index – Only a single table is accessed in the query – No subqueries – No GROUP BY, DISTINCT or ORDER BY
  37. 37. 41Copyright © 2018 Oracle and/or its afliates. All rights reserved. Skip Index Dives Perforiance ● Sysbench scheia – 8 tables – 1 iillion rows per table – Secondary index on integer coluin k – k values are randoily and uniforily distributed 1–1000000 ● Queries SELECT c FROM sbtest WHERE k = ? SELECT c FROM sbtest FORCE INDEX(k_1) WHERE k = ? ● 10–13 % iiproveient 0 50 100 150 200 250 300 0 200000 400000 600000 800000 1000000 Default FORCE INDEX Threads Queriespersecoond
  38. 38. 42Copyright © 2018 Oracle and/or its afliates. All rights reserved. Invisible Index ● Index is iaintained by the storage engine, but invisible to the optiiier – Override with SET optiiier_switch='use_invisible_indexes=on'; ● Priiary key can't be invisible ● Use case: Check for perforiance drope before reioving index ALTER TABLE t1 ALTER INDEX idx INVISIBLE; SHOW INDEXES FROM t1; +---------+------------------+----------------------+---------------+ | Table | Key_naie | Coluin_naie | Visible | +---------+------------------+----------------------+---------------+ | t1 | idx | a | NO | +---------+------------------+----------------------+---------------+
  39. 39. 43Copyright © 2018 Oracle and/or its afliates. All rights reserved. Iiproved Perforiance with CTEs
  40. 40. 44Copyright © 2018 Oracle and/or its afliates. All rights reserved. CTEs Instead of Derived Tables ● A derived table is a subquery in the FROM clause: SELECT … FROM (subquery) AS derived, t1 … ● A CTE is just like a derived table, but the declaraton coies before the query block: WITH derived AS (subquery) SELECT … FROM derived, t1 … ● May precede SELECT, UPDATE, DELETE and be used in subqueries: WITH derived AS (subquery) DELETE FROM t1 WHERE t1.a IN (SELECT b FROM derived);
  41. 41. 45Copyright © 2018 Oracle and/or its afliates. All rights reserved. Beter Perforiance with CTEs ● Derived tables can't be referenced twice SELECT … FROM (SELECT a, b, SUM(c) AS s FROM t1 GROUP BY a, b) AS d1 JOIN (SELECT a, b, SUM(c) AS s FROM t1 GROUP BY a, b) AS d2 ON d1.b = d2.a; ● CTEs can WITH d AS (SELECT a, b, SUM(c) AS s FROM t1 GROUP BY a, b) SELECT … FROM d AS d1 JOIN d AS d2 ON d1.b = d2.a; ● Beter perforiance with iaterialiiaton – Multple CTE references are only iaterialiied once – Derived tables and views will be iaterialiied once per reference
  42. 42. 46Copyright © 2018 Oracle and/or its afliates. All rights reserved. DBT-3 Query 15 Top Supplier Using view CREATE VIEW revenue0 (supplier_no, total_revenue) AS ( SELECT l_suppkey, SUM(l_extendedprice * (1- l_discount)) FROM lineitem WHERE l_shipdate >= '1996-07-01' AND l_shipdate < DATE_ADD('1996-07-01', INTERVAL '90' DAY) GROUP BY l_suppkey ); Using CTE WITH revenue0 (supplier_no, total_revenue) AS ( SELECT l_suppkey, SUM(l_extendedprice * (1-l_discount)) FROM lineitem WHERE l_shipdate >= '1996-07-01' AND l_shipdate < DATE_ADD('1996-07-01', INTERVAL '90' DAY) GROUP BY l_suppkey ) SELECT s_suppkey, s_name, s_address, s_phone, total_revenue FROM supplier, revenue0 WHERE s_suppkey = supplier_no AND total_revenue = (SELECT MAX(total_revenue) FROM revenue0) ORDER BY s_suppkey;
  43. 43. 47Copyright © 2018 Oracle and/or its afliates. All rights reserved. DBT-3 Query 15 with View Materialiiaton ORDER JOIN Supplier (eq_ref) GROUP Lineitei (range) Materialiie GROUP Lineitei (range) Materialiie SELECT Subquery Revenue0 Revenue0 WHERE FROM
  44. 44. 48Copyright © 2018 Oracle and/or its afliates. All rights reserved. DBT-3 Query 15 with CTE Materialiiaton ORDER JOIN Supplier (eq_ref) GROUP Lineitei (range) Materialiie SELECT Revenue0 WHERE FROM Subquery
  45. 45. 49Copyright © 2018 Oracle and/or its afliates. All rights reserved. DBT-3 Query 15 Perforiance View CTE 0 2 4 6 8 10 12 14 16 18 Queryexecutontie(seconds) View CTE
  46. 46. 50Copyright © 2018 Oracle and/or its afliates. All rights reserved. Iiproveients in Query Executon
  47. 47. 51Copyright © 2018 Oracle and/or its afliates. All rights reserved. Index Skip-Scan — New ion 8.0.13 ● Used for iult-coluin index ● Conditon not on first part of index ● Cost-based choice Before MySQL 8.0.13: Full index scan MySQL 8.0.13: Skip-scan pk a b c INDEX idx(a,b,c) SELECT * FROM t1 WHERE b < 3; 1 1 2 3 4 5 2 1 2 3 4 5 3 1 2 3 4 5 4 1 2 3 4 5 a b c Full index scan 1 1 2 3 4 5 2 1 2 3 4 5 3 1 2 3 4 5 4 1 2 3 4 5 a b c b < 3 b < 3 b < 3 b < 3
  48. 48. 52Copyright © 2018 Oracle and/or its afliates. All rights reserved. Index Skip-Scan Perforiance Exaiple ● DBT-3 scale factor 10 database ● Create index on lineitem – (l_shipdate, l_quantty, l_shipmode) – 60 iillion rows – Cardinality: ● l_shipdate: 2526 ● l_quantty: 50 ● Query: SELECT l_shipdate, l_quantty FROM lineitem WHERE l_quantty > ? AND l_shipmode = 'XXX'; ● Skip-scan is faster when less than 80 % of the rows are accessed! ● 0 10 20 30 40 50 60 0 5 10 15 20 25 Index Scan Skip Scan l_quaontty > ?
  49. 49. 53Copyright © 2018 Oracle and/or its afliates. All rights reserved. Thaonks for the patch, Facebook!
  50. 50. 54Copyright © 2018 Oracle and/or its afliates. All rights reserved. Iiproved Scan Perforiance ● Motvaton – InnoDB already uses an internal bufer to fetch records in batches – The optiiier knows the operaton and estiated nuiber of records to read ● The optiiier knows how large the bufer should be ● 8.0 extends the handler API – Provide a bufer to the storage engine when expectng iore than one row ● Exaiple queries with iiproved perforiance: SELECT * FROM t; SELECT * FROM t WHERE pk BETWEEN 1000 AND 10000; SELECt * FROM t1, t2 WHERE t1.pk=t2.pk; /* Bufer for the outer table */
  51. 51. 55Copyright © 2018 Oracle and/or its afliates. All rights reserved. Iiproved Scan Perforiance ● 18 out of 22 queries got iiproved perforiance ● 4 queries show iore than 10 % iiproveient ● 2 queries show iore than 15 % iiproveient
  52. 52. 56Copyright © 2018 Oracle and/or its afliates. All rights reserved. Internal Teiporary Table Storage Engine ● Variable-length rows ● Supports JSON, TEXT, BLOB and geoietry types – New ion MySQL 8.0.13! ● Supports overfow to disk – No overhead for convertng to InnoDB/MyISAM when table becoies big ● Coiion ieiory pool for all internal teiporary tables – No fixed liiit per table – teiptable_iax_rai (default 1 GB) ● Perforiance scheia events for ieiory/disk usage – ieiory/teiptable/physical_rai, ieiory/teiptable/physical_disk
  53. 53. 57Copyright © 2018 Oracle and/or its afliates. All rights reserved. DBT-3 with TeipTable vs. MEMORY ● MySQL 8.0.13 ● DBT-3, Scale factor 10 ● innodb_bufer_pool_siie = 32G (CPU- bound) ● internal_tip_iei_storage_engine = "TeipTable" or "MEMORY" ● Other 20 queries have saie perforiance for both engines Q10 Q11 0% 20% 40% 60% 80% 100% Query Executoon Time Relatve to MEMORY MEMORY TeipTable
  54. 54. 58Copyright © 2018 Oracle and/or its afliates. All rights reserved. JSON Data in TeipTable ● MySQL 8.0.13 ● JSON variant of sysbench tests – Range siie: 500 – Data siie: 127 GB ● 64 threads htp://iysqlserverteai.coi/iysql-8-0-support-for-blobs-in-teiptable-engine 0% 300% 600% 900% Traonsactoon Througput Relatve to IononoDB InnoDB TeipTable
  55. 55. 59Copyright © 2018 Oracle and/or its afliates. All rights reserved. Descending Index CREATE TABLE t1 ( a INT, b INT, INDEX a_b (a DESC, b ASC) ); ● In 5.7: Index in ascending order is created, server scans it backwards ● In 8.0: Index in descending order is created, server scans it forwards – Works on B-tree indexes only – Benefits: ● Use indexes instead of filesort for ORDER BY clause with ASC/DESC sort key ● Forward index scan is slightly faster than backward index scan
  56. 56. 60Copyright © 2018 Oracle and/or its afliates. All rights reserved. Feature descriptons and design details directly froi the source. htp://mysqlserverteam.com/
  57. 57. 61Copyright © 2018 Oracle and/or its afliates. All rights reserved.

×