当前位置:网站首页>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
边栏推荐
- idea plugins搜索不到插件
- SQLyog注释 添加 撤销 快捷键
- MySQL 删除表数据,重置自增 id 为 0 的两个方式
- WPS表格怎么自动1234排下去?wps表格怎么自动生成序号?
- 第04章 逻辑架构【1.MySQL架构篇】【MySQL高级】
- Recommendation System - Sorting Layer: Sorting Layer Architecture [User and Item Feature Processing Steps]
- 4年测试经验去面试10分钟就被赶出来了,面试官说我还不如应届生?都这么卷吗...
- 推荐系统:实时性【特征实时性:客户端实时特征(秒级,实时)、流处理平台(分钟级,近实时)、分布式批处理平台(小时/天级,非实时)】【模型实时性:在线学习、增量更新、全量更新】
- Swift简介
- Oblique document scanning and character recognition (opencv, coordinate transformation analysis)
猜你喜欢
随机推荐
CDH集群spark-shell执行过程分析
vlookup函数匹配不出来的原因及解决方法
“数字化重构系统,搞定 CEO 是第一步”
Weak Banks to data conversion ability?Matt software help solve bank dilemma
5分钟搞懂MySQL - 行转列
都在说软件测试没前途,饱和了?为何每年还会增加40万测试员?
英文字母间隔突然增大(全角与半角转换)
推荐系统:评估指标【离线评估指标:RMSE(均方根误差)、AUC、准确率、召回率、F1】【在线评估:A/B测试】【一般要求响应时间<0.5s】
mysqldump导出提示:mysqldump [Warning] Using a password on the command line interface can be insecure
【回归预测-lssvm分类】基于最小二乘支持向量机lssvm实现数据分类代码
推荐系统:概述【架构:用户/物品特征工程---->召回层---->排序层---->测试/评估】【冷启动问题、实时性问题】
推荐系统:冷启动问题【用户冷启动、物品冷启动、系统冷启动】
Recommendation System - Sorting Layer - Model (1): Embedding + MLP (Multilayer Perceptron) Model [Deep Crossing Model: Classic Embedding + MLP Model Structure]
银行数据资产转换能力弱?思迈特软件助力解决银行困境
化二次型为标准型
Apple Silicon配置二进制环境(一)
C语言中指针没那么难~ (1)【文章结尾有资料】
【回归预测-CNN预测】基于卷积神经网络CNN实现数据回归预测附matlab代码
MySQL的 DDL和DML和DQL的基本语法
[Ask] SQL statement to calculate the sum of column 2 by deduplicating column 1?









