当前位置:网站首页>Optimize the query (work in progress)
Optimize the query (work in progress)
2022-08-03 22:03:00 【penguin that wants to fly】
Scenario: Double-table joint query cannot be used, only by querying a single table, the query result can be used as the query condition of the second table.
Solution: First of all, it must be clear that java establishes query connections with the database many times, and the query will consume a lot of time. What optimization needs to be done is to reduce the time, so that the number of times that java establishes a connection with the database for query can be reduced.time.
Idea 1 (unoptimized): traverse the found data in Table 1, obtain the attributes required by the corresponding Table 2 during the traversal, and directly query it in Table 2 to obtain the results of Table 2 until the traversal ends.
Idea 2 (optimization): Find the data in Table 1, then put the data in Table 1 that needs to be used in Table 2 into the collection, and then query in Table 2 according to the data in the collection, and then inFilter the found data according to the conditional attributes to get the desired data.
It may be a bit laborious to say this, but the idea of optimization is to reduce the number of connections to the database, because this connection is time-consuming. Through the algorithm, the data range is too large by reducing the number of connections before.desired data.
边栏推荐
猜你喜欢
Pay from 0 to 1
2022年全国职业院校技能大赛网络安全 B模块 任务十windows操作系统渗透测试 国赛原题
CAS:1620523-64-9_Azide-SS-biotin_biotin-disulfide-azide
编译器工程师眼中的好代码(1):Loop Interchange
pikachu Over permission 越权
CAS:122567-66-2_DSPE-生物素_DSPE-Biotin
全球观之地理部分
主板设计中:网络变压器与RJ45网口之间应该保持什么样的距离?
Data_web(八)mysql增量同步到mongodb
[N1CTF 2018]eating_cms
随机推荐
XSS测试
Cisco ike2 IPSec配置
472. Concatenated Words
FVCOM 3D Numerical Simulation of Hydrodynamics, Water Exchange, Dispersion and Transport of Oil Spills丨FVCOM Model Watershed, Numerical Simulation Method of Marine Water Environment
《强化学习周刊》第56期:GraphIRL、REDEEMER & 眼科强化学习的潜在研究
[3D检测系列-PV-RCNN] PV-RCNN论文详解、PV-RCNN代码复现、包含官网PV-RCNN预训练权重及报错问题
6. XML
488. Zuma Game
主板设计中:网络变压器与RJ45网口之间应该保持什么样的距离?
21天打卡挑战学习MySQL——《Window下安装MySql》第一周 第三篇
软件测试人员必备的60个测试工具清单,建议收藏一波~
480. Sliding Window Median
382. Linked List Random Node
CAS:1260586-88-6_Biotin-C5-Azide_Biotin-C5-Azide
安全基础8 ---XSS
CAS:122567-66-2_DSPE-Biotin_DSPE-Biotin
Android build error: Plugin with id 'kotlin-android' not found.
斩获双奖|易知微荣获“2021中国数字孪生解决方案优秀供应商”“中国智能制造优秀推荐产品”双奖项!
CAS:1620523-64-9_Azide-SS-biotin_biotin-disulfide-azide
一些思考:腾讯股价为何持续都低