MySQL翻译系列-Window Function Restrictions

The SQL standard imposes a constraint on window functions that they cannot be used in UPDATE or DELETE statements to update rows. Using such functions in a subquery of these statements (to select rows) is permitted.

标准的SQL对窗口函数使用的update, delete语句中进行行更新进行约束. 但支持在这些语句的子查询中使用这样的函数(以选择行).

MySQL does not support these window function features:

MySQL不支持这些窗口特性:

  • DISTINCT syntax for aggregate window functions.
  • distinct语句用于聚合窗口函数
  • Nested window functions.
  • 嵌套窗口函数
  • Dynamic frame endpoints that depend on the value of the current row.
  • 基于当前行来决定边界(端点)的动态帧.

The parser recognizes these window constructs which nevertheless are not supported:

解析器识别这些窗口结构,但不支持:

  • The GROUPS frame units specifier is parsed, but produces an error. Only ROWS and RANGE are supported.
  • groups帧子集操作符被解析但是产生错误, 只有rows, range受到支持.
  • The EXCLUDE clause for frame specification is parsed, but produces an error.
  • EXCLUDE针对帧被解析, 但产生错误.
  • IGNORE NULLS is parsed, but produces an error. Only RESPECT NULLS is supported.
  • IGNORE NULLS的解析会产生一个错误, 只有RESPECT NULLS受到支持.
  • FROM LAST is parsed, but produces an error. Only FROM FIRST is supported.
  • FROM LAST的解析会产生一个错误, 只有FROM FIRST受到支持.

As of MySQL 8.0.28, a maximum of 127 windows is supported for a given SELECT. Note that a single query may use multiple SELECT clauses, and each of these clauses supports up to 127 windows. The number of distinct windows is defined as the sum of the named windows and any implicit windows specified as part of any window function's OVER clause. You should also be aware that queries using very large numbers of windows may require increasing the default thread stack size (thread_stack system variable).

8.0.28版本, select语句支持最多127窗口.

但是需要注意的是, 一个SQL语句可能使用有多个select子语句, 这里的支持的数量是针对子语句的select, 而不是整个SQL语句.

大量使用窗口函数将可能大幅度增加线程堆栈大小(负载的增大).