Entity Groups Query Performance

29 views
Skip to first unread message

savilak

unread,
Jun 16, 2012, 7:18:47 PM6/16/12
to google-a...@googlegroups.com
I have an ACCOUNT entity and then a child CONTACT entity. (1 Account has many Contacts).

I query to get 50 contacts:

DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();
Key accountKey = KeyFactory.createKey("Account", uid);
Query query = new Query("Contact").setAncestor(accountKey);
FetchOptions fetchOptions = FetchOptions.Builder.withLimit(50).prefetchSize(50);
QueryResultList<Entity> contacts = datastore.prepare(query).asQueryResultList(fetchOptions);

In case the Account has

300 Contacts  the query to get the first 50 contacts takes ----> 21  miliseconds
3000 Contacts the query to get the first 50 contacts takes   ----> 234  miliseconds 
10000 Contacts the query to get the first 50 contacts takes  ----> 1307  miliseconds 

Why is this the case? In all three cases I touch only the first 50 contacts.

Theory says Entity Grouping should not affect query performance.
Thank you for your time.


Reply all
Reply to author
Forward
0 new messages