Announcement Announcement Module
No announcement yet.
Why is findAllX() so slow out-of-the-box? Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Why is findAllX() so slow out-of-the-box?

    Hello everyone,

    I would be really grateful if someone could shed some light on my problem understanding the performance of some of Roo's JPA queries. To keep things simple, I just created a new Roo app (Roo 1.0.2, Hibernate+MySQL) featuring exactly one entity with two fields:

    public class Designer {
        private String name;
        private Boolean active;
    Now I am doing a findAllDesigners() like this:

    Stopwatch watch = SimonManager.getStopwatch("sampleapp.query-timer");
    Split split = watch.start();
    model.addAttribute("designers", Designer.findAllDesigners());
    I am using javasimon to time what is going on, but the time is also apparent to the "human eye".

    There are 5.000 rows in the designers table and it takes about 450ms on my MacBook Pro to get them.

    In another, non-Roo, app, I can easily get 10.000 even a little more complex entities in 1/10 of that time using basically the same libraries. There obviously are differences in the configuration but as that was my first Spring app there really is nothing "fancy" going on.

    Also, I realized, that the automatic integration test skips the "findAll" test if more than 250 objects are in the database as they are too "expensive to perform". So this seems to be expected by the authors of Roo.

    Why is that and why are these queries so "slow" out-of-the-box? Are these times "normal" (takes about ~500ms getting ~300 entities in the real app I am building)?
    I know that the configuration details would be needed to evaluate my specific setup but just consider the simple Roo app in which I did not change anything by hand and its strangely low performance.

    Thank you so much, this is really bugging me for some time now.

    Guess it is the @Configurable which leads to injecting the PersistenceContext. As soon as I take the Roo annotations out and get the data through a @Repository layer, speed is increased a lot (400ms down to 30ms after warm-up for 5000 objects), so that might be the trade-off.
    Last edited by Wolfram; Aug 4th, 2010, 03:59 AM.