What are your metrics if you remove the system.out.println statements? Maybe do all of that at the end so it is not factoring into your times. Print lines can be slow depending on the environment. As far as query creation using named queries is faster as the query then only needs to be parsed once not each time it is called. This will save you if the query is used often. As for the query itself make sure your tables are indexed properly.