Hi all!
I'm looking for a lesson from 'pricing oriented programming'. My service has a REST-style endpoint that I use to replicate/export/import data. Surprisingly export consumes ~10x more Datastore Small Operations than Datastore Read Operations. Thus I'm almost running out of free quota. There are ~2500 entities, the export does 10x count()s and reads all the data as follows:
public List getPage(Class clazz, int from, int to, int pageSize) {
PersistenceManager pm = getPm();
try {
Query queryStatement = pm.newQuery(clazz);
if(from==0) {
queryStatement.setRange(from, to);
} else {
if(from>0) {
Cursor cursor = Cursor.fromWebSafeString(getTablePageCursors.get(clazz));
Map<String, Object> extensionMap = new HashMap<String, Object>();
extensionMap.put(JDOCursorHelper.CURSOR_EXTENSION, cursor);
queryStatement.setExtensions(extensionMap);
queryStatement.setRange(0, pageSize);
}
}
List<?> queryResultList = (List<?>)queryStatement.execute();
Cursor cursor = JDOCursorHelper.getCursor(queryResultList);
getTablePageCursors.put(clazz, cursor.toWebSafeString());
...
} finally {
pm.close();
}
return result;
}
My question is what can I do to optimize the code. I don't think that count() is a problem. Can it be structure of entities exported? It seems that certain types consumer more small operations than others. Can it be caused by cursors?
Any suggestion or idea will be highly appreciated!