Spring Boot માં performance tuning મોટે ભાગે database boundary વિશે છે: connection pooling, caching, અને N+1 query problem ને મારવો. પહેલાં measure કરો (Micrometer + Actuator metrics), પછી સૌથી મોટા ખર્ચ પર હુમલો કરો.
N+1 problem — નંબર વન JPA killer
Lazy associations parent દીઠ એક query issue કરે છે, પછી દરેક child access દીઠ એક વધારાની:
List<Order> orders = orderRepo.findAll();
(Order o : orders) {
o.getItems().size();
}
