Since Monday, these simple SQL operations translate to expensive DataStore operations, why?

41 views
Skip to first unread message

Alberto Valaz

unread,
Nov 8, 2011, 2:07:05 PM11/8/11
to Google App Engine

I noticed that a number of simple SQL operations that my application
is dependent on generate very high quota usage.
Basically, one run of the three operations listed below are enough to
use up my daily free quota!!

Running appstats, I see a lot of "datastore_v3.Next" calls for the
first two calls. I assume I am doing something very wrong but I am not
sure how to fix it. Could anyone please give me some pointers on how
to address this?

thank you


PS. an interesting twist is that the below code worked just fine under
the old payment model.


---------------------
// The table Something below has around 50k rows. No indexes are used.

PersistenceManager pm = ...


// Select COUNT(*) from Something
Query q = pm.newQuery(Something.Class, null);
q.setResult("count(this)");
q.execute();



// select COUNT(*) from Something where 1234 > feild
Query q = pm.newQuery(Something.Class, "this.field > field");
q.declareParameters("Long field");
q.setResult("count(this)");
q.executeWithArray(1234);


// select * from Something order total DESC
Query q = pm.newQuery(Something.Class, null);
q.setOrdering("total DESC");
q.execute();

Alberto Valaz

unread,
Nov 8, 2011, 4:37:31 PM11/8/11
to Google App Engine
I noticed that a number of simple SQL operations that my application
is dependent on generate very high quota usage.
Basically, one run of the three operations listed below are enough to
use up my daily free quota!!


I assume I am doing something very wrong but I am not sure how to fix
it. Could anyone please give me

Denis Volokhovskiy

unread,
Nov 14, 2011, 2:27:49 PM11/14/11
to google-a...@googlegroups.com
Hi,

You should use sharded counter rather then count() function.
count() simply traverses all entities of the kind until reaches the last, so scales linearly with you data size.
I suppose you entities count simply raised much since Monday, so you have noticed that.

datastore is different...

karthik valsatech

unread,
Nov 14, 2011, 11:08:45 AM11/14/11
to google-a...@googlegroups.com
--
You received this message because you are subscribed to the Google Groups "Google App Engine" group.
To post to this group, send email to google-a...@googlegroups.com.
To unsubscribe from this group, send email to google-appengi...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-appengine?hl=en.


Reply all
Reply to author
Forward
0 new messages