当前位置:网站首页>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
边栏推荐
猜你喜欢
随机推荐
第04章 逻辑架构【1.MySQL架构篇】【MySQL高级】
使用MULTISET来比较数据集的实例介绍
Flex布局详解
推荐系统:实时性【特征实时性:客户端实时特征(秒级,实时)、流处理平台(分钟级,近实时)、分布式批处理平台(小时/天级,非实时)】【模型实时性:在线学习、增量更新、全量更新】
WPS没有在任务栏显示所有窗口选项怎么回事?
MySQL的on duplicate key update 的使用
MySQL Workbench 安装及使用
mysql 递归函数with recursive的用法
明解C语言第五章习题
【PM专用】快速统计团队还有谁没有登记上报信息,快速筛选出属于自己项目组的成员,未完成XXX工作事项的名单
ECCV2022 | 对比视觉Transformer的在线持续学习
移动web开发01
基于人脸的常见表情识别(2)——数据获取与整理
网络层协议------IP协议
啊?现在初级测试招聘都要求会自动化了?
TensorFlow2: Overview
Recommendation System - Sorting Layer: Sorting Layer Architecture [User and Item Feature Processing Steps]
KEIL问题:【keil Error: failed to execute ‘C:\Keil\ARM\ARMCC‘】
Scala类中的属性
什么是公约数









