views:

54

answers:

1

How can I determine how many sub-queries are required for a single top-level query on app engine (python)?

I am playing around with the IN operator, and I am curious if there is any way to be notified if I over-step my 30 sub-query limit.

+3  A: 

If you try to execute a query which would spawn too many sub-queries then you would get this error:

BadArgumentError: Cannot satisfy query -- too many subqueries (max: 30, got 31). Probable cause: too many IN/!= filters in query.

If you wanted to check before trying to execute the query, you could check the length of the list which you are passing query - as long as it has 30 or fewer elements the query will be okay (as long as you aren't using the != operator in the query too; if you are, then each != query will double the number of sub-queries that you would otherwise have).

David Underhill
David, what if I am passing a list to a property that is a ListProperty? Would the number of sub-queries be the product of the magnitude of the lists? I really wish the local datastore threw the same argument, I tried making mine throw that error and I couldn't get it to :/
Hamy
Hamy: A ListProperty just generates 1 index entry per item in the list; no additional subqueries are needed to query a ListProperty.
Wooble