mercredi 29 avril 2015

Grails design pattern for parallel queries using dynamic finders

Problem: We're querying our database with a lot of entries. The overall application performance is okay. But I think it could be better if our bottleneck, querying a special table, could be done parallel.

We are using for that dynamic finders like:

Object.findAllByObjectCollectionAndParentIsNullAndDeletedByUserIsNull(objectCollection, [sort: 'attr1.number', fetch: [objectType: 'eager']])

I think about this solution: Dividing the query into 2 steps.

  1. The first step loads only the Ids in a sorted way.
  2. The second step (could be done in parallel threads) loads the objects itself by the id and inserts it into the resultset.

I already googled for some hints about that, but find nothing.

  1. Is it possible, that it makes no sense?
  2. Or is there already a adequate solution in grails standard/extensions?
  3. If it makes sense and there is no solution: Can someone give me a hint implementing it? But, we need the ids in that sorted manner, explained in the example.

We're using grails 2.3.11, hibernate:3.6.10.13 with jdk 1.7 under it.

Aucun commentaire:

Enregistrer un commentaire