当前位置:网站首页>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.
边栏推荐
猜你喜欢
随机推荐
距LiveVideoStackCon 2022 上海站开幕还有3天!
4. 模块化编程
AI首席架构师13-AICA-智能文档分析技术在行业场景中的应用
gtk实现图片旋转
嵌入式系统:时钟
Go开发工具GoLand V2022.2 来了——Go 工作区重大升级
IO thread process -> thread synchronization mutual exclusion mechanism -> day6
HCIP第十三天
剑指 Offer 16. 数值的整数次方
全球观之地理部分
C. Array Elimination-- Codeforces Round #751 (Div. 2)
XSS online shooting range---prompt
如何基于WPF写一款数据库文档管理工具(二)
决策树、GBDT、XGBOOST树的可视化
CAS:1260586-88-6_生物素-C5-叠氮_Biotin-C5-Azide
如何基于WPF写一款数据库文档管理工具(二)
XSS漏洞复现
CAS:1620523-64-9_Azide-SS-biotin_生物素-二硫-叠氮
HCIP第十六天
for循环练习题









