A JOIN combines related rows from product and purchase tables in one query. It can replace code that retrieves purchases and then queries product details repeatedly. section 6.3.1
Use the investigation to connect database behavior with application code:
- Profile the JDBC traffic and count repeated queries. section 6.3.1
- Trace a query to the application method that sent it. section 6.3.1
- Replace the purchase query plus per-purchase product lookup with one query using a JOIN. section 6.3.1
Repeated product lookups
PurchaseService calls findAll(), loops over purchases, and invokes findProduct() for each item. Profiling showed the first query ran 10 times; merging the related retrieval into one JOIN query removes this faulty repetition. section 6.3.1















