当前位置:网站首页>2022-07-29 mysql/stonedb慢SQL-Q17-分析
2022-07-29 mysql/stonedb慢SQL-Q17-分析
2022-07-30 20:31:00 【帝尊悟世】
摘要:
对Q17慢SQL进行分析
SQL分析:
SQL:
/stonedb57/install/bin/mysql -D tpch -e "
select
sum(l_extendedprice) / 7.0 as avg_yearly
from
lineitem,
part
where
p_partkey = l_partkey
and p_brand = 'Brand#23'
and p_container = 'MED BOX'
and l_quantity < (
select
0.2 * avg(l_quantity)
from
lineitem
where
l_partkey = p_partkey
);
"
explain分析:
*************************** 1. row ***************************
id: 1
select_type: PRIMARY
table: lineitem
partitions: NULL
type: ALL
possible_keys: NULL
key: NULL
key_len: NULL
ref: NULL
rows: 59986052
filtered: 100.00
Extra: NULL
*************************** 2. row ***************************
id: 1
select_type: PRIMARY
table: part
partitions: NULL
type: eq_ref
possible_keys: PRIMARY
key: PRIMARY
key_len: 4
ref: tpch.lineitem.l_partkey
rows: 1
filtered: 5.00
Extra: Using where with pushed condition ((`tpch`.`part`.`p_brand` = 'Brand#23') and (`tpch`.`part`.`p_container` = 'MED BOX'))(t0) Pckrows: 16, susp. 16 (0 empty 0 full). Conditions: 2
*************************** 3. row ***************************
id: 2
select_type: DEPENDENT SUBQUERY
table: lineitem
partitions: NULL
type: ALL
possible_keys: NULL
key: NULL
key_len: NULL
ref: NULL
rows: 59986052
filtered: 10.00
Extra: Using where
| id | select_type | table | partitions | type | possible_keys | key | key_len | ref | rows | filtered | Extra |
| 1 | PRIMARY | lineitem | ALL | 59986052 | 100 | ||||||
| 1 | PRIMARY | part | eq_ref | PRIMARY | PRIMARY | 4 | tpch.lineitem.l_partkey | 1 | 5 | Using where with pushed condition ((`tpch`.`part`.`p_brand` = 'Brand#23') and (`tpch`.`part`.`p_container` = 'MED BOX'))(t0) Pckrows: 16, susp. 16 (0 empty 0 full). Conditions: 2 | |
| 2 | DEPENDENT SUBQUERY | lineitem | ALL | 59986052 | 10 | Using where |
热力图:

拆分SQL后分析:
外层表查询:
time /stonedb57/install/bin/mysql -D tpch -e "
select
l_extendedprice
from
lineitem,
part
where
p_partkey = l_partkey\G
"*************************** 1. row ***************************
id: 1
select_type: SIMPLE
table: lineitem
partitions: NULL
type: ALL
possible_keys: NULL
key: NULL
key_len: NULL
ref: NULL
rows: 59986052
filtered: 100.00
Extra: NULL
*************************** 2. row ***************************
id: 1
select_type: SIMPLE
table: part
partitions: NULL
type: eq_ref
possible_keys: PRIMARY
key: PRIMARY
key_len: 4
ref: tpch.lineitem.l_partkey
rows: 1
filtered: 100.00
Extra: NULL
内层查询:
time /stonedb57/install/bin/mysql -D tpch -e "
explain select
0.2 * avg(l_quantity)
from
lineitem \G
"*************************** 1. row ***************************
id: 1
select_type: SIMPLE
table: lineitem
partitions: NULL
type: ALL
possible_keys: NULL
key: NULL
key_len: NULL
ref: NULL
rows: 59986052
filtered: 100.00
Extra: NULL
边栏推荐
- WPS怎么独立窗口显示?wps单独窗口显示怎么操作?
- jOOQ是如何设计事务API(详细指南)
- ECCV2022 | 对比视觉Transformer的在线持续学习
- Recommendation System - Sorting Layer: Sorting Layer Architecture [User and Item Feature Processing Steps]
- 银行数据资产转换能力弱?思迈特软件助力解决银行困境
- Flink_CDC搭建及简单使用
- 7.联合索引(最左前缀原则)
- 第03章 用户和权限管理【1.MySQL架构篇】【MySQL高级】
- [Ask] SQL statement to calculate the sum of column 2 by deduplicating column 1?
- canvas基础讲解加示例
猜你喜欢
随机推荐
TensorFlow2:概述
使用map函数,对list中的每个元素进行操作 好像不用map
Redisson 的分布式锁找不到?
【请教】SQL语句按列1去重来计算列2之和?
【Codeforces思维题】20220728
KEIL问题:【keil Error: failed to execute ‘C:\Keil\ARM\ARMCC‘】
Flink_CDC搭建及简单使用
Apple Silicon配置二进制环境(一)
银行数据资产转换能力弱?思迈特软件助力解决银行困境
HMS Core Discovery第16期回顾|与虎墩一起,玩转AI新“声”态
[NISACTF 2022]下
@Transactional注解在类上还是接口上使用,哪种方式更好?
推荐系统:实时性【特征实时性:客户端实时特征(秒级,实时)、流处理平台(分钟级,近实时)、分布式批处理平台(小时/天级,非实时)】【模型实时性:在线学习、增量更新、全量更新】
MySql 创建索引
bebel系列- 插件开发
利用go制作微信机器人
MySQL ODBC驱动简介
对int变量赋值的操作是原子的吗?
推荐系统-排序层-模型(一):Embedding + MLP(多层感知机)模型【Deep Crossing模型:经典的Embedding+MLP模型结构】
MYSQL JDBC图书管理系统









