Slow JPA? Use Daobab!

Did you noticed, how slow your database query is, speccially when you attach related entities by @OneToMany for example?
Don't you think it's a paradox in case of relational database?

Why JPA is so slow?

Why? Because many sql queries are executed on the backgroud.
Example: The city has 150 libraries. You want to select list of them... but each library has hidden relation @OneToMany to List of Books.
How many queries will be executed? One? No... 151 because each of the library need to get a list of books as well
Books cataloque is large, so each query need more much time.

That's why many things like Lazy Loading or various cache has been involved.
But if fact, it not helps much.

How Daobab can speed up the queries?

Yes, Daobab is an JPA compatibile extention, but Daobab is able to query over in-memory buffers, and the buffers might be query result.
Daobab doesn't need to describe entities relations pernamently on the entity level, and you decide whether you need books... or not.
If you need only libraries - select only libraries - one query only.
If you want libraries together with books, use the trick:

  • 1. Select all books connected to libraries from the city (one query)
  • 2. Select libraries from the city, but in the completeEach(Select books from the buffer taken in point 1)

Result: 2 queries sent to database. 150 queries executed in the blink of eye in memory.
This is how, with Daobab you can make your query 150x faster.
In this approach you can select not only one relation but also deeper... and still your query remain fast.