当前位置:网站首页>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
边栏推荐
- 2021年PHP-Laravel面试题问卷题 答案记录
- MySQL group_concat()详解
- Office365无法打开word文档怎么办?Office365无法打开word文档的解决方法
- 微信读书,导出笔记
- vookloop函数怎么用?vlookup函数的使用方法介绍
- vlookup函数匹配不出来只显示公式的解决方法
- Running the evict task with compensationTime
- 【回归预测-CNN预测】基于卷积神经网络CNN实现数据回归预测附matlab代码
- 推荐系统:实时性【特征实时性:客户端实时特征(秒级,实时)、流处理平台(分钟级,近实时)、分布式批处理平台(小时/天级,非实时)】【模型实时性:在线学习、增量更新、全量更新】
- Oblique document scanning and character recognition (opencv, coordinate transformation analysis)
猜你喜欢
随机推荐
5分钟搞懂MySQL - 行转列
服务器不稳定因素
软考 --- 数据库(6)数据仓库、分布式数据库
银行数据资产转换能力弱?思迈特软件助力解决银行困境
Based on the face of the common expression recognition - model building, training and testing
PHP低代码开发引擎—表单设计
mysql 递归函数with recursive的用法
2021年PHP-Laravel面试题问卷题 答案记录
MySQL----多表查询
MVC模式和三层架构
MySQL_关于JSON数据的查询
excel数字下拉递增怎么设置?
18.客户端会话技术Cookie
如何解决gedit 深色模式下高亮文本不可见?
想要写出好的测试用例,先要学会测试设计
halcon——轮廓线
基于人脸的常见表情识别(1)——深度学习基础知识
canvas基础讲解加示例
MySQL 高级(进阶) SQL 语句 (一)
【视频】极值理论EVT与R语言应用:GPD模型火灾损失分布分析