当前位置:网站首页>MySQL uses or to query SQL, and SQL execution is very slow
MySQL uses or to query SQL, and SQL execution is very slow
2022-04-23 04:59:00 【GreatorMan】
When the company makes a one-stop service hall , The interface returns slowly due to data reasons . An interface returns to 90S;
According to the interface analysis , Found the program executing SQL I found some more data executing SQL Time is slow , One SQL It takes time to run 30S about .
SELECT DISTINCT
t.id AS appId,
t.priority
FROM
yzs_unified_app t
LEFT JOIN yzs_unified_app_theme t1 ON t.id = t1.app_id
LEFT JOIN yzs_app_unified_role t2 ON t.id = t2.app_id
LEFT JOIN yzs_user_unified_role t3 ON t2.role_id = t3.role_id
LEFT JOIN yzs_app_unified_dept_post t4 ON t.id = t4.app_id
LEFT JOIN yzs_user_unified_dept_post t5 ON t4.dept_post_id = t5.dept_post_id
WHERE
(
t3.user_id = '1185405911867326464' or t5.dept_post_id = -2
)
and t1.theme_id = 5
t3 The table data has 1W Number of multiple , T5 Yes 100 Multiple data ;
When SQL
t5.dept_post_id = -2 or t3.user_id = '1185405911867326464'
After replacing the above conditions, I found that soon
Our analysis found that T3 The filtered data exists in the table at Don't appear very slowly , Each piece of data needs to be traversed 1W Number of pieces ;
solve the problem :
stay On Filter data conditionally ,
SELECT DISTINCT
t.id AS appId,
t.priority
FROM
yzs_unified_app t
LEFT JOIN yzs_unified_app_theme t1 ON t.id = t1.app_id
LEFT JOIN yzs_app_unified_role t2 ON t.id = t2.app_id
LEFT JOIN yzs_user_unified_role t3 ON t2.role_id = t3.role_id and t3.user_id = '1185405911867326464'
LEFT JOIN yzs_app_unified_dept_post t4 ON t.id = t4.app_id
LEFT JOIN yzs_user_unified_dept_post t5 ON t4.dept_post_id = t5.dept_post_id and t5.dept_post_id = -2
WHERE
t1.theme_id = 5
Or subquery :
.............................
版权声明
本文为[GreatorMan]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204220553102358.html
边栏推荐
- 机器学习---线性回归
- 使用model.load_state_dict()时,出现AttributeError: ‘str‘ object has no attribute ‘copy‘
- MySQL memo (for your own query)
- 《2021多多阅读报告》发布,95后、00后图书消费潜力攀升
- Excel uses the functions of replacement, sorting and filling to comprehensively sort out financial data
- Windows remote connection to redis
- Knowledge points sorting: ES6
- Raspberry pie + opencv + opencv -- face detection ------- environment construction
- Informatics Aosai yibentong 1212: letters | openjudge 2.5 156: Letters
- The object needs to add additional attributes. There is no need to add attributes in the entity. The required information is returned
猜你喜欢
Simply drag objects to the item bar
使用model.load_state_dict()时,出现AttributeError: ‘str‘ object has no attribute ‘copy‘
深度学习笔记 —— 语义分割和数据集
Deep learning notes - semantic segmentation and data sets
Spark small case - RDD, spark SQL
What are the redis data types
Innovation training (IV) preliminary preparation - server
多线程基本概念(并发与并行、线程与进程)和入门案例
Learning Android from scratch -- Introduction
Pixel 5 5g unlocking tutorial (including unlocking BL, installing edxposed and root)
随机推荐
DIY 一个 Excel 版的子网计算器
No such file or directory problem while executing shell
Opencv + clion face recognition + face model training
Jetpack -- lifecycle usage and source code analysis
Customize the navigation bar at the top of wechat applet (adaptive wechat capsule button, flex layout)
[WinUI3]編寫一個仿Explorer文件管理器
Set Chrome browser background to eye protection (eye escort / darkreader plug-in)
How can continuous integration (CI) / continuous delivery (CD) revolutionize automated testing
Excel uses the functions of replacement, sorting and filling to comprehensively sort out financial data
Getprop property
JS determines whether the numeric string contains characters
Wechat payment function
vscode ipynb文件没有代码高亮和代码补全解决方法
AQS源码阅读
ApplicationContext injection bean
Details related to fingerprint payment
什么是指令周期,机器周期,和时钟周期?
机器学习---线性回归
[database] MySQL multi table query (I)
深度学习笔记 —— 语义分割和数据集