Tagged articles
Nested Loop
12 articles · Page 1 of 1
This article walks through a common Java scenario of matching two large lists with nested loops, measures the poor performance, then demonstrates two optimizations—adding a break statement and replacing the inner loop with a HashMap—to dramatically cut execution time.
AlgorithmHashMapJava
0 likes · 6 min read

This article demonstrates how to dramatically speed up Java data‑matching operations that use nested for‑loops by breaking early when a match is found and by converting the inner list into a HashMap for O(1) lookups, showing code examples, performance measurements, and practical tips for backend developers.
HashMapJavaNested Loop
0 likes · 7 min read

To avoid the O(n × m) cost of naïve nested loops when matching IDs, replace the inner scan with a break after a unique match or, far more efficiently, build a HashMap of the secondary list so each lookup becomes O(1), dropping overall complexity to O(n + m) and cutting execution time from tens of seconds to a few hundred milliseconds.
HashMapJavaNested Loop
0 likes · 8 min read

This article demonstrates how to replace inefficient nested for‑loops that match user IDs between two large lists with a map‑based lookup, showing code examples, performance measurements, and the impact of using break statements and O(1) hash map access to dramatically reduce execution time.
JavaNested Loopmap
0 likes · 9 min read

This article demonstrates how replacing a costly nested‑loop search for matching user IDs with a pre‑built HashMap dramatically reduces processing time from tens of seconds to a few seconds, explaining the underlying time‑complexity benefits and providing complete Java code examples.
HashMapNested Loopcollections
0 likes · 6 min read

This article uses a realistic interview scenario to explore why multi-table joins in MySQL are not inherently slow, detailing four join algorithms—simple nested-loop, index nested-loop, block nested-loop, and batched key access—along with their pseudo‑code, execution steps, performance trade‑offs, and the impact of features like MRR and recent optimizer changes.
Index JoinJoin AlgorithmsMySQL
0 likes · 10 min read

This article analyzes a common Java scenario of nested for‑loops over large user and user‑memo lists, demonstrates the performance impact of adding a break statement, and shows how converting the inner list to a HashMap can reduce execution time from tens of seconds to a few seconds.
HashMapNested Loop
0 likes · 9 min read

This article analyzes a slow Join query on OceanBase 3.2.3.3, examines execution plans and table statistics, proposes two rewrite methods—adding a filter condition and using a hash‑join hint—and demonstrates how these changes reduce execution time from over 500 seconds to just a few seconds.
Database PerformanceNested LoopOceanBase
0 likes · 12 min read

This article explains why hash joins usually outperform nested‑loop joins, how to force hash joins in SQL, the data‑type restrictions that prevent hash joins, and practical tips for optimizing join performance in TD and Oracle compatibility modes.
Hash JoinNested LoopSQL
0 likes · 6 min read

This article explains the purpose and configuration of MySQL's join_buffer_size for INNER JOIN operations without indexed join keys, compares Nested Loop, Block Nested Loop, and the newly introduced Hash Join algorithms, and shows how each affects execution plans and query performance.
MySQLNested Loopblock nested loop
0 likes · 8 min read

This article explains how SQL optimizers choose join methods and table order, compares nested loop and merge joins, outlines factors influencing table selection, and offers practical guidance for improving multi‑table query performance.
Database PerformanceMerge JoinNested Loop
0 likes · 8 min read

Learn practical techniques to reduce nested loop iterations, prioritize inner-loop optimization, ensure join columns are indexed, and configure join buffers effectively, so your SQL joins run with minimal resource consumption and maximum performance.
Database PerformanceIndexingNested Loop
0 likes · 3 min read
