Tagged articles
12 articles
Page 1 of 1
Java Web Project
Java Web Project
Jun 25, 2025 · Backend Development

How to Speed Up Nested Loops in Java: Break and Map Tricks

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.

HashMapJavaNested Loop
0 likes · 6 min read
How to Speed Up Nested Loops in Java: Break and Map Tricks
macrozheng
macrozheng
Mar 11, 2025 · Backend Development

Boost Java Loop Performance: Replace Nested Loops with Map Lookups

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
Boost Java Loop Performance: Replace Nested Loops with Map Lookups
Java Tech Enthusiast
Java Tech Enthusiast
Feb 1, 2025 · Backend Development

Optimizing Nested Loops in Java with Map and Break

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.

HashMapJavaMAP
0 likes · 8 min read
Optimizing Nested Loops in Java with Map and Break
Top Architect
Top Architect
Dec 20, 2024 · Backend Development

Optimizing Nested Loops in Java Using Map for Faster ID Matching

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.

JavaMAPNested Loop
0 likes · 9 min read
Optimizing Nested Loops in Java Using Map for Faster ID Matching
Java Captain
Java Captain
Nov 19, 2024 · Backend Development

Optimizing Nested Loop Data Matching with a Map in Java

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.

CollectionsHashMapNested Loop
0 likes · 6 min read
Optimizing Nested Loop Data Matching with a Map in Java
Senior Tony
Senior Tony
Jul 4, 2024 · Databases

Why MySQL Joins Aren’t Always Slow: Inside the Four Join Algorithms

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 AlgorithmsNested Loop
0 likes · 10 min read
Why MySQL Joins Aren’t Always Slow: Inside the Four Join Algorithms
Aikesheng Open Source Community
Aikesheng Open Source Community
Feb 29, 2024 · Databases

Optimizing Nested-Loop Join Performance in OceanBase: Analysis, Rewrites, and Results

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 PerformanceJOIN optimizationNested Loop
0 likes · 12 min read
Optimizing Nested-Loop Join Performance in OceanBase: Analysis, Rewrites, and Results
MaGe Linux Operations
MaGe Linux Operations
Feb 12, 2024 · Databases

Why Hash Join Beats Nested Loop Join and When It Fails

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.

Data TypesHash JoinNested Loop
0 likes · 6 min read
Why Hash Join Beats Nested Loop Join and When It Fails
Aikesheng Open Source Community
Aikesheng Open Source Community
Nov 1, 2019 · Databases

Understanding MySQL join_buffer_size and Join Algorithms (Nested Loop, Block Nested Loop, Hash Join)

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.

Nested Loopblock nested loopjoin_buffer_size
0 likes · 8 min read
Understanding MySQL join_buffer_size and Join Algorithms (Nested Loop, Block Nested Loop, Hash Join)