当前位置:网站首页>Tikv & tiflash accelerates complex business queries
Tikv & tiflash accelerates complex business queries
2022-07-21 00:16:00 【Tidb community dry goods portal】
One 、TiKV Bank deposit And TiFlash Column storage mixed use
TiDB in query Schematic diagram of execution , You can see in the TiDB In a query The implementation of will be divided into two parts , Part of it is TiDB perform , Some are pushed down to the storage tier ( TiFlash/TiKV ) perform .
1.1 Mixing principle
1 | TiDB Row column mixing is not a choice between row storage and column storage in traditional design , It is TiDB You can have row storage and column storage at the same time in the same table , And the two always maintain strong data consistency ( Not the final agreement ). |
---|---|
2 | Multiple table queries use different engines TIKV or TiFlash . |
3 | TiFlash Support MPP Query execution of pattern , That is, cross node data exchange is introduced into the calculation (data shuffle The process ). |
1.2 Mix optimization
Two 、 Advanced filtering of labeling system
Through the label ( From the wide list of uncertain fields ) And narrow table specific fields to query customers and page
2.1 Read from TiKV
SELECT /*+ READ_FROM_STORAGE(tikv[b], tikv[c],tikv[d]) */ a.*, b.CUST_NAME,b.CERT_TYPE,b.CERT_NUM,b.CUST_TYPE,b.SEX,b.AGE,b.BIRTH_DT, c.ORG_ID,c.ORG_NAME, d.ASSET,d.ASSET_MON_AVG FROM ( SELECT /*+ READ_FROM_STORAGE(tikv[m],tikv[n]) */ m.cust_id FROM m_cust_label m RIGHT JOIN m_cust_org n ON m.CUST_ID = n.CUST_ID WHERE m.cat1 IN ( 516, 710, 230,3301 ) AND n.ORG_ID IN ( '133','8716', '7162') ORDER BY n.cust_id ASC LIMIT 100 ) a LEFT JOIN m_cust_main b ON a.cust_id = b.cust_id LEFT JOIN m_cust_org c ON a.cust_id = c.cust_id LEFT JOIN m_cust_data d ON a.cust_id = d.cust_id ;
4G,2c virtual machine 300 All the data , First execution 48 s Second execution 0.7s
2.2 Read From TiKV & TiFlash
SELECT /*+ READ_FROM_STORAGE(tikv[b], tikv[c],tikv[d]) */ a.*, b.CUST_NAME,b.CERT_TYPE,b.CERT_NUM,b.CUST_TYPE,b.SEX,b.AGE,b.BIRTH_DT, c.ORG_ID,c.ORG_NAME, d.ASSET,d.ASSET_MON_AVG FROM ( SELECT /*+ READ_FROM_STORAGE(tiflash[m],tikv[n]) */ m.cust_id FROM m_cust_label m RIGHT JOIN m_cust_org n ON m.CUST_ID = n.CUST_ID WHERE m.cat1 IN ( 516, 710, 230,3301 ) AND n.ORG_ID IN ( '133','8716', '7162') ORDER BY n.cust_id ASC LIMIT 100 ) a LEFT JOIN m_cust_main b ON a.cust_id = b.cust_id LEFT JOIN m_cust_org c ON a.cust_id = c.cust_id LEFT JOIN m_cust_data d ON a.cust_id = d.cust_id
4G,2c virtual machine 300 All the data , First execution 3s Second execution 0.3s
2.3 TiFlash & MPP
set @@session.tidb_allow_mpp=1;set @@session.tidb_enforce_mpp=1;
SELECT /*+ READ_FROM_STORAGE(tikv[b], tikv[c],tikv[d]) */ a.*, b.CUST_NAME,b.CERT_TYPE,b.CERT_NUM,b.CUST_TYPE,b.SEX,b.AGE,b.BIRTH_DT, c.ORG_ID,c.ORG_NAME, d.ASSET,d.ASSET_MON_AVG FROM ( SELECT /*+ READ_FROM_STORAGE(tiflash[m],tiflash[n]) */ m.cust_id FROM m_cust_label m RIGHT JOIN m_cust_org n ON m.CUST_ID = n.CUST_ID WHERE m.cat1 IN ( 516, 710, 230,3301 ) AND n.ORG_ID IN ( '133','8716', '7162') ORDER BY n.cust_id ASC LIMIT 100 ) a LEFT JOIN m_cust_main b ON a.cust_id = b.cust_id LEFT JOIN m_cust_org c ON a.cust_id = c.cust_id LEFT JOIN m_cust_data d ON a.cust_id = d.cust_id
Use MPP Mode to execute the query, and then turn on ,4G 2c virtual machine 300 All the data , First execution 1s Second execution 0.15s
2.4 SPM Fixed execution plan
CREATE GLOBAL|SESSION BINDING for <BindableStmt > USING <BindableStmt2>SHOW GLOBAL|SESSION BINDINGS ; -- View the binding plan explain format = 'verbose' <BindableStmt2>;show warnings; -- Through execution show warnings Understand the SQL Which statement is used binding
Fixed specific queries go TiFlash Inventory query .
3、 ... and 、 Ranking of value institutions under the label
3.1 According to the selected attribute ( Multivalued )
Those who use these values most are in the top 3 Institutions , And calculate the total amount
3.2 Implementation plan
table:c go TiFlash ;table:a, table:b go TiKV , At the same time, it uses the advantages of column storage and row storage .
Four 、 summary
Use TiKV and TiFlash It can speed up complex queries , Use scenarios are simply added below .
Components | Description of applicable scenarios |
---|---|
TiKV | The search condition is fixed , And there's an index |
TiFlash | The search conditions are not fixed , Unable to quote |
TiKV + TiFlash | The search conditions of some tables are not fixed , Some tables have indexes |
If there is any improper description, please comment and correct !
thank you PingCAP Strong community support !
The author of this article : Border town Yuanyuan
边栏推荐
- If paging by frame fails - solution
- 将流转化为数据产品
- [NepCTF2022] 复现
- BiliBili live broadcast partition page automatically retrieves the red envelope live broadcast room and jumps to it
- DOM basic operation
- 哔哩哔哩 直播分区页面 自动检索红包直播间并跳转
- 什麼是複制沖突
- . Net uses its own Di batch injection service and backgroundservice
- el-table 用formatter 将接口返回的 多个数字类型的字符串 转换成对应汉字
- Windows11 install MySQL 5.7 X nanny graphic tutorial
猜你喜欢
FAQ - build a business security platform architecture. Here are all the answers you want!
COLA 4.0 - DDD项目实践
Prometheus has released the long-term supported version of LTS
Windows11 install MySQL 5.7 X nanny graphic tutorial
Yolov5 trains its own VOC dataset
软件性能测试方案-性能测试准备
【技术人才懂的浪漫】TiDB 社区为你准备好了给另一半的“七夕节”礼物,人人都有份哟!
哔哩哔哩 直播分区页面 自动检索红包直播间并跳转
小程序“getLocation:fail fail:require permission desc“获取请求地址失败
What are the common methods of functional testing of Web testing? What are the main points to pay attention to?
随机推荐
RS485 Serial Communications¶
centos8 裝MYSQL
Two duplicate operations with different functions in blender
mysql insert 存在即不插入语法
Component architecture project construction - gradle unified, dependent management and configuration
1235. 规划兼职工作 动态规划
Probability prediction of wind power generation based on short term (realized by matlab code)
[postman] use tests to set environment variables
性能测试报告包括哪些内容?模板范文哪里找?看这里
windows11安装MySQL5.7.X保姆级图文教程
About authorizingrealm unable to inject service
CF 809div2 DE
第八章:区间[ %d,%d]内等差素数列,改进等差素数列
Devil cold rice | 103 devil sees the economy; Uncompleted residential flats, rental rider, Zhouyi and reservoir quality men
【Try to Hack】sql注入 Less7 (into outfile和布尔盲注)
嗶哩嗶哩 直播分區頁面 自動檢索紅包直播間並跳轉
cpolar应用实例之助力航运客户远程办公
blender中功能不同的两种duplicate操作
[e-commerce operation] try these five personalized marketing methods to bid farewell to ineffective marketing!
method