当前位置:网站首页>2022 - 07 - 18 sous - Requête - optimisation du traitement de l'optimiseur de requête join pour le scénario exists
2022 - 07 - 18 sous - Requête - optimisation du traitement de l'optimiseur de requête join pour le scénario exists
2022-07-22 14:56:00 【L'empereur respecte le monde éclairé】
Résumé:
Explique comment optimiserexistsDejoinTraitement de l'optimiseur de requête
Fonctions de base:
TwoDimensionalJoiner::ChooseJoinAlgorithm
JoinAlgType TwoDimensionalJoiner::ChooseJoinAlgorithm([[maybe_unused]] MultiIndex &mind, Condition &cond) { JoinAlgType join_alg = JoinAlgType::JTYPE_GENERAL; if (cond[0].IsType_JoinSimple() && cond[0].op == common::Operator::O_EQ) { if ((cond.Size() == 1) && !stonedb_sysvar_force_hashjoin) join_alg = JoinAlgType::JTYPE_MAP; // available types checked inside else join_alg = JoinAlgType::JTYPE_HASH; } else { if (cond[0].IsType_JoinSimple() && (cond[0].op == common::Operator::O_MORE_EQ || cond[0].op == common::Operator::O_MORE || cond[0].op == common::Operator::O_LESS_EQ || cond[0].op == common::Operator::O_LESS)) join_alg = JoinAlgType::JTYPE_SORT; } return join_alg; }
Sélectionnerjoin Analyse des problèmes d'optimisation :
- Juge seulement join simpleScénario,Non jugéexistsClause
- cond[0].IsType_JoinSimple() Si on entre elseBranches, C'est l'équivalent d'être exécuté deux fois
ChooseJoinAlgorithmOptimisation des fonctions:
- AdhésionexistsJugement, Par IsType_JoinSimple Et == common::Operator::O_EQ Traitement conditionnel
- Optimiser la structure du Code, Nettoyer les redondants cond[0].IsType_JoinSimple()Mise en œuvre
- Aucune autre logique n'est modifiée
JoinAlgType TwoDimensionalJoiner::ChooseJoinAlgorithm([[maybe_unused]] MultiIndex &mind, Condition &cond) { JoinAlgType join_alg = JoinAlgType::JTYPE_GENERAL; do { if (cond[0].IsExists()) { break; } if (!cond[0].IsType_JoinSimple()) { return join_alg; } if (cond[0].op == common::Operator::O_EQ) { break; } if (cond[0].op == common::Operator::O_MORE_EQ || cond[0].op == common::Operator::O_MORE || cond[0].op == common::Operator::O_LESS_EQ || cond[0].op == common::Operator::O_LESS) { join_alg = JoinAlgType::JTYPE_SORT; return join_alg; } } while (0); if ((cond.Size() == 1) && !stonedb_sysvar_force_hashjoin) join_alg = JoinAlgType::JTYPE_MAP; // available types checked inside else join_alg = JoinAlgType::JTYPE_HASH; return join_alg; }
Après optimisation du CodeexistsAnalyse de scénarios:
- Si la force n'est pas activée hash joinRequête, Etcond.Size() == 1, Oui.JTYPE_MAPRequête
- Ouverture forcée requise hash joinPour entrerhash joinRequête, Le test actuel n'ouvre pas la force hash join. ParJTYPE_MAPEffectuer des tests
Optimiser la marche JTYPE_MAPTest de requête:
MAP Les sous - requêtes prennent du temps :
mysql> select -> o_orderpriority, -> count(*) as order_count -> from -> orders -> where -> o_orderdate >= date '1993-07-01' -> and o_orderdate < date '1993-07-01' + interval '3' month -> and exists ( -> select -> * -> from -> lineitem -> where -> l_orderkey = o_orderkey -> and l_commitdate < l_receiptdate -> ) -> group by -> o_orderpriority -> order by -> o_orderpriority ; +-----------------+-------------+ | o_orderpriority | order_count | +-----------------+-------------+ | 1-URGENT | 114839 | | 2-HIGH | 114276 | | 3-MEDIUM | 114716 | | 4-NOT SPECIFIED | 114913 | | 5-LOW | 114927 | +-----------------+-------------+ 5 rows in set (1.46 sec)
MAP Les sous - requêtes prennent du temps par rapport aux sous - requêtes précédentes :
JTYPE_MAP Diagramme logique de flamme
Forcez - vous.JTYPE_HASHTest de requête:
Force ouvertehash joinOptimisation, Comparez le même scénario avec mapDifférences de requête
HASH Les sous - requêtes prennent du temps :
mysql> select -> o_orderpriority, -> count(*) as order_count -> from -> orders -> where -> o_orderdate >= date '1993-07-01' -> and o_orderdate < date '1993-07-01' + interval '3' month -> and exists ( -> select -> * -> from -> lineitem -> where -> l_orderkey = o_orderkey -> and l_commitdate < l_receiptdate -> ) -> group by -> o_orderpriority -> order by -> o_orderpriority ; +-----------------+-------------+ | o_orderpriority | order_count | +-----------------+-------------+ | 1-URGENT | 114839 | | 2-HIGH | 114276 | | 3-MEDIUM | 114716 | | 4-NOT SPECIFIED | 114913 | | 5-LOW | 114927 | +-----------------+-------------+ 5 rows in set (1.36 sec)
HASH Sous - requête par rapport à la Sous - requête précédente :
HASH Diagramme de flamme pour la Sous - Requête :
边栏推荐
- Usage and cases of regexp of MySQL statement
- 【AGC】构建服务1-云函数示例
- 【HarmonyOS】【FAQ】鸿蒙问题合集4
- 【HMS core】【Analytics Kit】【FAQ】如何解决华为分析付费分析中付款金额显示为0的问题?
- 排错-通过LLDP信息查找环路(以H3C S5100为例)
- 【HMS core】【ML Kit】机器学习服务常见问题FAQ(二)
- 这一次,彻底梳理各种布局问题
- Sequence table and linked list (sequence table)
- STM32 RT thread porting lvgl
- 顺序表与链表(顺序表)
猜你喜欢
Configuring laradock under winodos
Checking the wide IP range of SPF records will undermine the security of e-mail
[try to hack] SYN Flood and CC attack
LabVIEW cluster cannot contain input and output controls at the same time
LabVIEW簇中不能同时包含输入输出控件
三体攻击----三维差分+二分+坐标映射
AE case 1: character split screen tutorial
How to do a good job in analyzing credit derivatives and credit card data scenarios? This time series feature method needs to be learned | what financial and credit analysts must learn
Deveco studio3.0 download failed, prompting an unknown error occurred
Practice of online problem feedback module (10): realize image preview function
随机推荐
Sword finger offer special assault edition day 6
[harmonyos] [FAQ] Hongmeng problem collection 4
排错-通过LLDP信息查找环路(以H3C S5100为例)
OS8 resource based priority inversion and priority ceiling protocol
[MySQL series] addition, deletion, modification and query of MySQL tables (Advanced)
My creation anniversary
2022-07-20 mysql-hashJoin说明
Shanghaofang - project summary
AOSP ~ Camera - RK HAL3 ( 二 )
Mysql语句的RegExp的用法与案例
三星提出XFormer | 超越MobileViT、DeiT、MobileNet等模型
【MySQL系列】“一勞永逸“ 解决MySQL中 “插入中文數據“出錯的問題
322. Change exchange ●●
[wechat applet] choosebao - the Savior of choice difficulties
UDS03-根据标识符写入数据服务【ServiceID = 0x2E】
Redis----三大特殊数据类型、事务、整合、配置文件、持久化rdb和aof、发布订阅、主从复制(哨兵模式)、缓存穿透和雪崩
感知机+激活函数+多层感知机的实现
2022.7.11-7.17 AI industry weekly (issue 106): just try your best
Y73. Chapter IV Prometheus big factory monitoring system and actual combat -- blackbox exporter installation and grafana installation (IV)
6、学习MySQL 删除数据库