Sunday 15 January 2012

gae datastore - Projection queries with zigzag merge -



gae datastore - Projection queries with zigzag merge -

i utilize projection queries on appengine zigzag merge. appears requires projected property included in every index used zigzag merge query. in utilize case result in entity update costs high.

to illustrate, below simple illustration using java low-level datastore api , using indices index(e, p1, p3) , index(e, p2, p3); works duplicates p3 property of entity e in 2 indices.

// create sample entity 3 (indexed) properties. datastoreservice datastore = datastoreservicefactory.getdatastoreservice(); entity e = new entity("e"); e.setproperty("p1", 1); e.setproperty("p2", 1); e.setproperty("p3", 1); datastore.put(e); // query above entity projection on property p3. query q = new query("e"); filter filter1 = new filterpredicate("p1", filteroperator.equal, 1); filter filter2 = new filterpredicate("p2", filteroperator.equal, 1); q.setfilter(compositefilteroperator.and(filter1, filter2)); q.addprojection(new propertyprojection("p3", integer.class)); preparedquery pq = datastore.prepare(q); pq.aslist(fetchoptions.builder.withdefaults());

i'd remove 1 of composite indices, index(e, p2, p3), , rely on default index property p2, reducing update costs. doing results in datastoreneedindexexception @ runtime.

note similar problem occurs if maintain above 2 indices add together 4th property 1 of them , include 4th property in projection. utilize of default index hence not seem problem.

so question: there way of doing projection queries zigzag merge without duplicating projected properties across indices? if not, i'd understand underlying technical reason is.

any pointers appreciated.

ok, see why projected property needs duplicated in involved indices: because index sort order has same in relevant index blocks (two in example) zigzag merge work.

in example, lastly sort order done on projected property. when index removed changes sort order, , new sort of indexes needed work.

so, don't think i'm after possible on appengine @ moment. new dedicated appengine feature required enable indexed properties not impact index sort order.

gae-datastore google-datastore google-app-engine

No comments:

Post a Comment