0

Again, I'm creating this thread to see if someone has the same issues or if someone knows how to improve performance. Let me explain first the scenario: I have a JDO entity named for example Product. In that product I have a field of another entity, a simple one (Example Type: long id, String name, String value) and 1 date. I created 10000 objects of the product but when i try to query the Product with the dates the performance is good but if I add the type.id == 12 then the performance drops from 100ms to 30 secs... if I instead of having a Type object put a long typeId on the Product, then the same query is also fast... What I'm worried is with scalability, should I flatten the structures and work with ids that are not really connected but needs additional application retrieval or is there a way to improve performance on the query on a Product.Type? Thank you very much in advance.

I've already tried to define fetchGroups, but they don't really work...

What I wanted to do actually is doing a sort of mapping via an ID on the Product, but I couldn't do it with the embedded annotation...

so, let me explain a little better: I have a class named Reading with (one Date timeStamp and a Product p). this is doing a query. If the filter is something like this:

String filter = "timeStamp > fromDate && timeStamp < toDate";

the query executes in 100ms if I do this

String filter = "timeStamp > fromDate && timeStamp < toDate && prod.id == '941'"

for example, it takes 30secs... I've seen the logs, and without the query for the product he only reads from cache, if I add the clause of the Product he seems to fetch all the objects and starts comparing values I imagine...I don't really know what to do, maybe I should disconnect all these classes and start using like a String productID on the Reading class and then everything starts to be fast again... but in reality, the connection is not there, it would be implemented in an application layer... Thanks again... Any advise?

The query generated is something like this: SELECT FROM core.jdo.model.Readings WHERE timeStamp > fromDate && timeStamp < toDate && EAN.EAN == '002' PARAMETERS java.util.Date fromDate, java.util.Date toDate import java.util.Date

Neil Stockton
  • 11,383
  • 3
  • 34
  • 29
  • errm, look at the log ? That tells you the timings *of the datastore*, as well as many other things. A fetchGroup "works" in what it is intended to do ... fetch more fields in one call – Neil Stockton Feb 27 '15 at 13:33
  • Thanks for the reply... will look at the log now... but it seems like he's doing this on all cases... should I flatten the Relations between them and join the data in an application layer? – Rodrigo Carvalheira Feb 27 '15 at 14:02
  • You don't present the actual operations that you think are "slow" and what is happening in the datastore for those. That is how you identify what is wrong and what can be changed. So the persist is slow? or a query is slow? so present your code for that operation. – Neil Stockton Feb 27 '15 at 14:21
  • Thank you for the fast reply again. so, let me explain a little better: – Rodrigo Carvalheira Feb 27 '15 at 14:28
  • Thank you for the fast reply again. so, let me explain a little better: I have a class named Reading with (one Date timeStamp and a Product p). this is doing a query. If the filter is something like this: String filter = "timeStamp > fromDate && timeStamp < toDate"; the query executes in 100ms if I add this " && prod.id == '941'" for example, it takes 30secs... I've seen the logs, and without the query for the product he only reads from cache, if I add the clause of the Product he seems to fetch all the objects and starts comparing values I imagine... – Rodrigo Carvalheira Feb 27 '15 at 14:35
  • I don't really know what to do, maybe I should disconnect all these classes and start using like a String productID on the Reading class and then everything starts to be fast again... but in reality, the connection is not there, it would be implemented in an application layer... Thanks again... Any advise? – Rodrigo Carvalheira Feb 27 '15 at 14:35
  • you still don't say WHAT is the query executed in the database, and what log entries there are for the second query ... all of them. No idea what you mean by embedded annotation ... if you want to embed an object in another then do it, I use embedded 1-1 relations with MongoDB – Neil Stockton Feb 27 '15 at 15:27
  • Hi Neil, I edited the question and added the query generated... I see from the logs that he's fetching the value of the subclass for each row... the thing is that the subclass (is an attribute of the main class) has only 5 values, but he iterates 10k times... Could i load those 5 values into memory instead of DN fetching them all for all the rows? This is quite weird, I hope I don't run into problems this way... maybe I should have gone to JPA instead of JDO, there's a lot more control with annotations, is really more into Relational DBs than NOSQL, but I really don't know how to solve this... – Rodrigo Carvalheira Feb 27 '15 at 16:34
  • No that is NOT the query executed in the database. MongoDB doesn't do queries of that form. – Neil Stockton Feb 27 '15 at 17:21
  • No idea what you talk about "maybe I should have gone with JPA" and "more control with annotations". JDO has annotations, and annotations give no more control. Why not actually debug your issue, like looking at the MongoDB query? – Neil Stockton Feb 27 '15 at 18:34

0 Answers0