MySQL-5.7-8.2.2 Optimizing Subqueries, Derived Tables, and View References(优化子查询、派生表和视图引用)

本文详细介绍了MySQL查询优化器在处理子查询和派生表时的不同策略,包括半联结、具体化和EXISTS策略。对于IN、NOT IN子查询以及派生表和视图引用,分别阐述了优化选项。注意,UPDATE和DELETE语句中的子查询优化存在限制,建议使用多表联接重写。
摘要由CSDN通过智能技术生成

8.2.2.1 Optimizing Subqueries, Derived Tables, and View References with Semijoin Transformations

8.2.2.2 Optimizing Subqueries with Materialization

8.2.2.3 Optimizing Subqueries with the EXISTS Strategy

8.2.2.4 Optimizing Derived Tables and View References with Merging or Materialization

The MySQL query optimizer has different strategies available to evaluate subqueries:

MySQL查询优化器有不同的策略来评估子查询:

For IN (or =ANY) subqueries, the optimizer has these choices:

对于IN (or =ANY)子查询,优化器有以下选择:

  • Semijoin

  • 半联结
  • Materialization

  • 具体化
  • EXISTS strategy

  • EXISTS  策略

For NOT IN (or <>ALL) subqueries, the optimizer has these choices:

对于NOT IN(或<>ALL)子查询,优化器有以下选择:

  • Materialization

  • EXISTS strategy

For derived tables, the optimizer has these choices (which also apply to view references):

对于派生表,优化器有这些选择(也适用于视图引用):

  • Merge the derived table into the outer query block

  • 派生表合并到外部查询块中
  • Materialize the derived table to an internal temporary table

  • 派生表具体化为内部临时表

The following discussion provides more information about the preceding optimization strategies.

面的讨论提供了关于上述优化策略的更多信息。

Note

A limitation on UPDATE and DELETE statements that use a subquery to modify a single table is that the optimizer does not use semijoin or materialization subquery optimizations.

使用子查询修改单个表的UPDATE和DELETE语句的一个限制是,优化器不使用半连接或具体化子查询优化。

As a workaround, try rewriting them as multiple-table UPDATE and DELETE statements that use a join rather than a subquery.

作为一种解决方案,尝试将它们重写为使用联接而不是子查询的多表UPDATE和DELETE语句。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值