技术大牛养成指南:吃的草够多,你也能成为大牛(附思维导图)

本文涉及的产品
云数据库 RDS MySQL,集群系列 2核4GB
推荐场景:
搭建个人博客
RDS MySQL Serverless 基础系列,0.5-2RCU 50GB
云数据库 RDS PostgreSQL,集群系列 2核4GB
简介:

非常高兴的向大家宣布MySQL 8.0 GA版本发布,MySQL 8.0是一个得到全面增强且极具吸引力的新版本。不限于下面几点:

We proudly announce General Availability of MySQL 8.0. Download now! MySQL 8.0 is an extremely exciting new version of the world’s most popular open source database with improvements across the board. Some key enhancements include:

1、SQL方面:窗口函数,公共表达式,NOWAIT, SKIP LOCKED, 降序索引,分组,正则表达式,字符集,CBO优化模式,直方图

1、SQL Window functions, Common Table Expressions, NOWAIT and SKIP LOCKED, Descending Indexes, Grouping, Regular Expressions, Character Sets, Cost Model, and Histograms.

2、对JSON的支持:扩充语法,新函数,排序增强,JSON列部分更新。基于JSON表的特性,可以调用SQL语句处理JSON数据。

2、JSON Extended syntax, new functions, improved sorting, and partial updates. With JSON table functions you can use the SQL machinery for JSON data.

3、对地理信息系统的支持—空间引用系统(SRS),包括SRS空间数据类型,空间索引,空间函数

3、GIS Geography support. Spatial Reference Systems (SRS), as well as SRS aware spatial datatypes, spatial indexes, and spatial functions.

4、可靠性:DDL语句支持原子性和崩溃安全恢复(元信息数据被存在了一个基于InnoDB的单独事务性数据字典中)。

4、Reliability DDL statements have become atomic and crash safe, meta-data is stored in a single, transactional data dictionary. Powered by InnoDB!

5、可观察性:对P_S,I_S,配置参数,错误日志的记录有显著增强5、Observability Significant enhancements to Performance Schema, Information Schema, Co

nfiguration Variables, and Error Logging.

6、可管理性:远程管理,Undo表空间管理,快速DDL

6、Manageability Remote management, Undo tablespace management, and new instant DDL.

7、安全性:OpenSSL的改进,新的默认验证方式,SQL角色权限,分解super权限,密码强度提升等等

7、Security OpenSSL improvements, new default authentication, SQL Roles, breaking up the super privilege, password strength, and more.

8、性能:InnoDB在读/写负载,高IO负载,热数据高并发竞争等场景表现更好。新增的资源组特性给用户在特定负载和特定硬件情况下将用户线程映射到指定的CPU上的可选项

8、Performance InnoDB is significantly better at Read/Write workloads, IO bound workloads, and high contention “hot spot” workloads. Added Resource Group feature to give users an option optimize for specific workloads on specific hardware by mapping user threads to CPUs.

以上是8.0版本的部分亮点,我(原文作者)推荐您仔细阅读GA版本前几个版本的发布信息,甚至这些特性和实现方法的的项目日志。或者您可以选择直接在Github上阅读源码。

The above represents some of the highlights and I encourage you to further drill into the complete series of Milestone blog posts—8.0.0, 8.0.1, 8.0.2, 8.0.3, and 8.0.4 —and even further down in to the individual worklogs with their specifications and implementation details. Or perhaps you prefer to just look at the source code at github.com/mysql.

面向开发人员的特性

MySQL 8.0应面向MySQL开发人员的需求,带来了SQL,JSON,正则表达式,地理信息系统等方面的特性,因为很多开发人员有存储EmoJi表情的需求,在新版本中UTF8MB4成为默认的字符集。除此之外,还有对Binary数据类型按位操作,和对IPV6和UUID函数的改进。

MySQL Developers want new features and MySQL 8.0 delivers many new and much requested features in areas such as SQL, JSON, Regular Expressions, and GIS. Developers also want to be able to store Emojis, thus UTF8MB4 is now the default character set in 8.0. Finally there are improvements in Datatypes, with bit-wise operations on BINARY datatypes and improved IPv6 and UUID functions.

SQL

1、窗口函数

MySQL 8.0带来了标准SQL的窗口函数功能,窗口函数与分组聚合函数相类似的是都提供了对一组行数据的统计计算。但与分组聚合函数将多行合并成一行不同是窗口函数会在结果结果集中展现每一行的聚合。

MySQL 8.0 delivers SQL window functions. Similar to grouped aggregate functions, window functions perform some calculation on a set of rows, e.g. COUNT or SUM. But where a grouped aggregate collapses this set of rows into a single row, a window function will perform the aggregation for each row in the result set.

窗口函数有两种使用方式,首先是常规的SQL聚合功能函数和特殊的窗口函数。

常规的聚合功能函数如:COUNT,SUM等函数。而窗口函数专有的则是RANK, DENSE_RANK, PERCENT_RANK, CUME_DIST, NTILE, ROW_NUMBER, FIRST_VALUE, LAST_VALUE, NTH_VALUE, LEADand LAG等函数。

Window functions come in two flavors: SQL aggregate functions used as window functions and specialized window functions. This is the set of aggregate functions in MySQL that support windowing: COUNT, SUM, AVG, MIN, MAX, BIT_OR, BIT_AND, BIT_XOR, STDDEV_POP (and its synonyms STD, STDDEV), STDDEV_SAMP, VAR_POP (and its synonym VARIANCE) and VAR_SAMP. The set of specialized window functions are: RANK, DENSE_RANK, PERCENT_RANK, CUME_DIST, NTILE, ROW_NUMBER, FIRST_VALUE, LAST_VALUE, NTH_VALUE, LEADand LAG

对窗口函数的支持上,是用户呼声比较频繁。窗口函数早在SQL2003规范中就成为了标准SQL的一部分。

Support for window functions (a.k.a. analytic functions) is a frequent user request. Window functions have long been part of standard SQL (SQL 2003). See blog post by Dag Wanvik here as well as blog post by Guilhem Bichot here.

2、公用表表达式(CTE)

MySQL 8.0 带来了支持递归的公用表表达式的功能。非递归的公用表表达式由于允许由from子句派生的临时表的原因可以被多次引用,因而被解释为改进型的派生表(from子句中的临时表)。

而递归的公用表表达式则由一组原始数据,经过处理后得到新的一组数据,再被带入处理得到更多的新数据,循环往复直到再也无法产生更多新数据为止。公用表达式也是一个用户呼声频繁的SQL功能。

MySQL 8.0 delivers [Recursive] Common Table Expressions (CTEs). Non-recursive CTEs can be explained as “improved derived tables” as it allow the derived table to be referenced more than once. A recursive CTE is a set of rows which is built iteratively: from an initial set of rows, a process derives new rows, which grow the set, and those new rows are fed into the process again, producing more rows, and so on, until the process produces no more rows. CTE is a commonly requested SQL feature, see for example feature request 16244 and 32174 . See blog posts by Guilhem Bichot here, here, here, and here.

3、新的NOWAIT、SKIP LOCKED选项

MySQL 8.0 给SQL的上锁子句带来了NOWAIT和SKIP LOCKED两个可选项。在原来的版本中,当行数据被UPDATE或者SELECT ... FOR UPDATE语句上锁后,其他的事务需要等待锁释放才能访问这行数据。

但在某些场景下,有马上获得(不等待锁)数据的需求。使用NOWAIT参数后如果请求的数据中包括了被锁住的行,将马上会收到查询失败的报错信息。使用SKIP LOCKED参数后,返回的数据将会跳过被锁住的行。

MySQL 8.0 delivers NOWAIT and SKIP LOCKED alternatives in the SQL locking clause. Normally, when a row is locked due to an UPDATE or a SELECT ... FOR UPDATE, any other transaction will have to wait to access that locked row. In some use cases there is a need to either return immediately if a row is locked or ignore locked rows. A locking clause using NOWAIT will never wait to acquire a row lock. Instead, the query will fail with an error. A locking clause using SKIP LOCKED will never wait to acquire a row lock on the listed tables. Instead, the locked rows are skipped and not read at all. NOWAIT and SKIP LOCKED are frequently requested SQL features. See for example feature request 49763 . We also want to say thank you to Kyle Oppenheim for his code contribution! See blog post by Martin Hansson here.

4、降序索引

MySQL 8.0 带来了对降序索引的支持。在 8.0降序索引中,数据被倒序组织,正向查找。而在之前的版本中,虽然支持创建降序排列的索引,但其实现方式是通过创建常见的正序索引,然后进行反向查找来实现的。

一方面,正序查找要比逆序查找更快;

另一方面,真正的降序索引在复合的order by语句(即有asc又有desc)中,可以提高索引利用率,消除filesort。

MySQL 8.0 delivers support for indexes in descending order. Values in such an index are arranged in descending order, and we scan it forward. Before 8.0, when a user create a descending index, we created an ascending index and scanned it backwards. One benefit is that forward index scans are faster than backward index scans. Another benefit of a real descending index is that it enables us to use indexes instead of filesort for an ORDER BY clause with mixed ASC/DESC sort key parts. Descending Indexes is a frequently requested SQL feature. See for example feature request 13375 . See blog post by Chaithra Gopalareddy here.

5、分组函数

MySQL 8.0 带来了GROUPING()分组函数,这个功能可以把group by子句扩展功能(如ROLLUP)产生的过聚合NULL值,通过0和1进行区分,1为NULL,这样就可以在having子句中对过聚合的无效值进行过滤。

MySQL 8.0 delivers GROUPING(), SQL_FEATURE T433. The GROUPING() function distinguishes super-aggregate rows from regular grouped rows. GROUP BY extensions such as ROLLUP produce super-aggregate rows where the set of all values is represented by null. Using the GROUPING() function, you can distinguish a null representing the set of all values in a super-aggregate row from a NULL in a regular row. GROUPING is a frequently requested SQL feature. See feature requests 3156 and 46053. Thank you to Zoe Dong and Shane Adams for code contributions in feature request 46053 ! See blog post by Chaithra Gopalareddy here.

6、优化器建议

在5.7版本中我们引入了新的优化器建议的语法,借助这个新的语法,优化器建议可以被用/*+ */包裹起来,直接放在SELECT | INSERT | REPLACE | UPDATE | DELETE关键字的后面。

在8.0的版本中我们又加入了新的姿势:

In 5.7 we introduced a new hint syntax for optimizer hints. With the new syntax, hints can be specified directly after the SELECT | INSERT | REPLACE | UPDATE | DELETEkeywords in an SQL statement, enclosed in /*+ */ style comments. (See 5.7 blog post by Sergey Glukhov here). In MySQL 8.0 we complete the picture by fully utilizing this new style:

d47e62d2b349aca45e42305ed6714efbe5ed61d9 8.0版本增加了INDEX_MERGE和NO_INDEX_MERGE,允许用户在单个查询中控制是否使用索引合并特性。
MySQL 8.0 adds hints for INDEX_MERGE and NO_INDEX_MERGE. This allows the user to control index merge behavior for an individual query without changing the optimizer switch.

d47e62d2b349aca45e42305ed6714efbe5ed61d98.0版本增加了JOIN_FIXED_ORDER, JOIN_ORDER, JOIN_PREFIX, 和 JOIN_SUFFIX,允许用户控制join表关联的顺序。

MySQL 8.0 adds hints for JOIN_FIXED_ORDER, JOIN_ORDER, JOIN_PREFIX, and JOIN_SUFFIX. This allows the user to control table order for the join execution.

d47e62d2b349aca45e42305ed6714efbe5ed61d98.0版本增加了SET_VAR,该优化器建议可以设定一个只在下一条语句中生效的的系统参数。

MySQL 8.0 adds a hint called SET_VAR. The SET_VAR hint will set the value for a given system variable for the next statement only. Thus the value will be reset to the previous value after the statement is over. See blog post by Sergey Glukhov here.

相对于之前的优化器建议和优化器特性开关参数,我们更倾向于推荐新形式的优化器建议模式,新形式的优化器建议可以在不侵入SQL语句(指修改语句的非注释的业务部分)的情况下,注入查询语句的很多位置。与直接修改语句的优化器建议相比,新形势的优化器建议在SQL语义上更加清晰。

We prefer the new style of optimizer hints as preferred over the old-style hints and setting of optimizer_switch values. By not being inter-mingled with SQL, the new hints can be injected in many places in a query string. They also have clearer semantics in being a hint (vs directive).

JSON

8.0版本追加了新的JSON函数,并可以提高在排序与分组JSON数据情况下的性能。

MySQL 8.0 adds new JSON functions and improves performance for sorting and grouping JSON values.

1、JSON path表达式中扩展的范围性语法

MySQL 8.0 扩展了JSON path表达式中范围性的语法,比如:SELECT JSON_EXTRACT('[1, 2, 3, 4, 5]', '$[1 to 3]');可以得出[2, 3, 4]的结果。

MySQL 8.0 extends the syntax for ranges in JSON path expressions. For example SELECT JSON_EXTRACT('[1, 2, 3, 4, 5]', '$[1 to 3]'); results in [2, 3, 4].

The new syntax introduced is a subset of the SQL standard syntax, described in SQL:2016, 9.39 SQL/JSON path language: syntax and semantics. See also Bug#79052reported by Roland Bouman.

2、JSON表函数

MySQL 8.0 增加了可以在JSON数据上使用SQL处理工具的JSON 表函数。JSON_TABLE()函数可以创建JSON数据的关系型视图。可以将JSON数据估算到关系型的行列之中,用户可以对此函数返回的数据按照常规关系型数据表的方式进行SQL运算。

MySQL 8.0 adds JSON table functions which enables the use of the SQL machinery for JSON data. JSON_TABLE() creates a relational view of JSON data. It maps the result of a JSON data evaluation into relational rows and columns. The user can query the result returned by the function as a regular relational table using SQL, e.g. join, project, and aggregate.

3、JSON 聚合函数

MySQL 8.0 增加了用于生成JSON阵列的聚合函数JSON_ARRAYAGG(),和用于生成JSON对象的JSON_OBJECTAGG()函数,令多行的JSON文档组合成JSON阵列或者JSON对象成为可能。

MySQL 8.0 adds the aggregation functions JSON_ARRAYAGG() to generate JSON arrays and JSON_OBJECTAGG() to generate JSON objects . This makes it possible to combine JSON documents in multiple rows into a JSON array or a JSON object. See blog post by Catalin Besleaga here.

4、JSON 合并函数

JSON_MERGE_PATCH() 函数可执行JavaScript的语法,在合并时发生重复键值对时将会优先选用第二个文档的键值对,并删除第一个文档对应的重复键值。

The JSON_MERGE_PATCH() function implements the semantics of JavaScript (and other scripting languages) specified by RFC7396, i.e. it removes duplicates by precedence of the second document. For example, JSON_MERGE('{"a":1,"b":2 }','{"a":3,"c":4 }');# returns {"a":3,"b":2,"c":4}.

JSON_MERGE_PRESERVE()函数与5.7版本中的JSON_MERGE()含义相同,都是在合并的时候保留所有值。

The JSON_MERGE_PRESERVE() function has the semantics of JSON_MERGE() implemented in MySQL 5.7 which preserves all values, for example JSON_MERGE('{"a": 1,"b":2}','{"a":3,"c":4}'); # returns {"a":[1,3],"b":2,"c":4}.

5.7原来的JSON_MERGE() 函数在8.0版本中为减少merge操作的不明确性,而被弃用。

The existing JSON_MERGE() function is deprecated in MySQL 8.0 to remove ambiguity for the merge operation. See also proposal in Bug#81283 and blog post by Morgan Tocker here.

5、JSON 美化函数

8.0版本增加了可以接收JSON原生数据类型和用字符串形式表达的JSON,并返回一行缩进的易读的JSON格式化后的的字符串。

MySQL 8.0 adds a JSON_PRETTY() function in MySQL. The function accepts either a JSON native data-type or string representation of JSON and returns a JSON formatted string in a human-readable way with new lines and indentation.

6、JSON 文件大小函数

8.0版本增加了和指定JSON对象空间占用相关的函数,JSON_STORAGE_SIZE() 可以用字节为单位返回JSON某个数据类型的实际大小, JSON_STORAGE_FREE() 可以返回该JSON数据类型的剩余空间(包括碎片和用来适应更改后发生长度变化的预备空间)

MySQL 8.0 adds JSON functions related to space usage for a given JSON object. The JSON_STORAGE_SIZE() returns the actual size in bytes for a JSON datatype. The JSON_STORAGE_FREE() returns the free space of a JSON binary type in bytes, including fragmentation and padding saved for inplace update.

7、JSON 改进型的排序

8.0版本通过使用变长的排序键提升了JSON排序分组的性能。在某些场景下,Preliminary 的压测结果出现了1.2到18倍的提升。

MySQL 8.0 gives better performance for sorting/grouping JSON values by using variable length sort keys. Preliminary benchmarks shows from 1.2 to 18 times improvement in sorting, depending on use case.

8、JSON的部分更新

8.0版本增加了对 JSON_REMOVE(), JSON_SET() 和 JSON_REPLACE() 函数的部分更新的支持。如果JSON文档的某部分被更新,我们会将更改的详情给到句柄。这样存储引擎和复制关系就不必写入整个JSON文档。

在之前的复制环境中由于无法确保JSON文档的排列(layout)在主从上完全一致,所以在基于行的复制情况下物理文件的差异并不能用来削减传输复制信息带来的网络IO消耗。

因此,8.0版本提供了在逻辑上区分差异的方法,可以在行复制的情况下传输并应用到从库上。

MySQL 8.0 adds support for partial update for the JSON_REMOVE(), JSON_SET() and JSON_REPLACE() functions. If only some parts of a JSON document are updated, we want to give information to the handler about what was changed, so that the storage engine and replication don’t need to write the full document. In a replicated environment, it cannot be guaranteed that the layout of a JSON document is exactly the same on the slave and the master, so the physical diffs cannot be used to reduce the network I/O for row-based replication. Thus, MySQL 8.0 provides logical diffs that row-based replication can send over the wire and reapply on the slave. See blog post by Knut Anders Hatlen here.


原文发布时间为:2018-05-15
本文作者:张锐志
本文来自云栖社区合作伙伴“ 老叶茶馆”,了解相关信息可以关注“ 老叶茶馆”。
相关实践学习
如何在云端创建MySQL数据库
开始实验后,系统会自动创建一台自建MySQL的 源数据库 ECS 实例和一台 目标数据库 RDS。
全面了解阿里云能为你做什么
阿里云在全球各地部署高效节能的绿色数据中心,利用清洁计算为万物互联的新世界提供源源不断的能源动力,目前开服的区域包括中国(华北、华东、华南、香港)、新加坡、美国(美东、美西)、欧洲、中东、澳大利亚、日本。目前阿里云的产品涵盖弹性计算、数据库、存储与CDN、分析与搜索、云通信、网络、管理与监控、应用服务、互联网中间件、移动服务、视频服务等。通过本课程,来了解阿里云能够为你的业务带来哪些帮助     相关的阿里云产品:云服务器ECS 云服务器 ECS(Elastic Compute Service)是一种弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。产品详情: https://www.aliyun.com/product/ecs
相关文章
|
算法 Linux C语言
【我的创作之路】CSDN陪我走过的256个日夜
【我的创作之路】CSDN陪我走过的256个日夜
170 0
|
2月前
|
算法 JavaScript 前端开发
探索编程之美:从小白到大牛的旅程
【10月更文挑战第9天】编程,这个听起来高深莫测的词汇,实际上就像是一场奇妙的探险。它不仅仅是冷冰冰的代码和算法,更是一扇打开新世界大门的钥匙。本文将带你领略编程的魅力所在,从最初的迷茫与困惑,到逐渐找到自己的方向,最终在技术的海洋里遨游。无论你是编程新手,还是希望进一步提升的开发者,都能在这段旅程中找到属于自己的光芒。
|
17天前
|
机器学习/深度学习 人工智能 自然语言处理
探索编程之美:从小白到大牛的代码旅程
在编程的世界里,每一行代码都是探险者的脚步,每一个bug都是成长的印记。本文将带你领略编程的魅力,从最初的迷茫到技术的熟练,一起感受那些日夜与代码为伴的日子如何塑造一个程序员的思维和人生。
|
6月前
|
Rust 算法 JavaScript
编程入行指南:从代码小白到技术大牛的“码农”奇幻漂流
编程入行指南:从代码小白到技术大牛的“码农”奇幻漂流
|
3月前
|
算法 Python
编程之道:从小白到大牛的蜕变之路
【9月更文挑战第25天】在编程的世界里,每个人都是从零开始,但并非每个人都能成为大牛。本文将通过深入浅出的方式,分享我从编程小白到大牛的蜕变之路,包括学习编程的初衷、遇到的困难、解决问题的方法和心得体会。希望我的经历能给你带来启示和鼓舞,让你在编程的道路上越走越远。
|
3月前
|
人工智能 自动驾驶 数据挖掘
探索代码之美:从小白到大牛的编程之旅
【9月更文挑战第4天】编程,一种将思维转化为现实的神奇艺术。本文将以通俗易懂的方式,带领读者走进编程的世界,从基础概念到实际案例,逐步揭示编程的魅力和挑战。无论你是编程新手,还是有一定经验的开发者,都能在这篇文章中找到属于自己的启示和成长路径。让我们一起开启这场探索代码之美的旅程吧!
40 5
|
3月前
|
Java 开发者 Python
编程之道:从小白到大牛的心路历程
【9月更文挑战第1天】编程,不仅仅是敲击键盘、编写代码那么简单。它是一种思维的锻炼,一种解决问题的艺术,更是一种生活的态度。本文将带你走进编程的世界,从最初的迷茫与困惑,到逐渐找到方向,再到深入探索与提升,最后实现自我价值的蜕变。让我们一起感受编程的魅力,体验技术的力量。
|
前端开发 数据可视化 程序员
程序员如何过码农特色的中秋?
程序员如何过码农特色的中秋?
119 0
|
前端开发 程序员 C#
第72个儿童节,程序猿“童”样精彩~
第72个儿童节,程序猿“童”样精彩~
135 1
第72个儿童节,程序猿“童”样精彩~
|
存储 算法 程序员
想当程序猿?或许你需要这个书单-程序猿修炼之路(上)
转眼间暑假就快到了。与其咸鱼懒得翻身,还不如坐下来,静下心找几本书安安静静看完。那么,小编在这里给大家推荐几本程序猿的练级攻略吧。
154 0
想当程序猿?或许你需要这个书单-程序猿修炼之路(上)
下一篇
DataWorks