I am trying to do some simple reporting in the datastore viewer in GAE. Using GQL I want to show just a few fields of a record. Is this possible?
How do I take entity with fields:
f1 f2 f3 f4 f5 f6
and show
f1 f3 f5 f6
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
This is not possible. From the GQL Reference documentation:
And from the Differences with SQL section of the datastore overview:
As for why this kind of limitation exists, the article about How Entities and Indexes are Stored gave a good insight regarding the technical aspect behind Google’s Bigtable, the distributed database system powering App Engine’s datastore. (And other Google products)
From the article, datastore entities are stored in several different Bigtables. An
Entity Bigtablestores the entire properties of the entity, and severalIndex Bigtablesstores the entity key sorted according to indexes of the entity.When we perform a query, basically there are two step that happen. The first step is our query is being executed against the
Index Bigtables, producing a set of entity key that matches our query. The second step is that the set of keys is then used to fetch the whole entity from theEntity Bigtable.Therefore, when you execute your query starting with
SELECT __key__, the datastore only need to do the first step and immediately return with the set of keys. When you execute your query starting withSELECT *, the datastore did both steps and return with the set of entities.Now, regarding why queries like
SELECT f1, f3, f5, f6is not supported by the datastore, we need to look into further detail on what happened during the second step stated above. From the article, it is stated that on theEntity Bigtable:Since the low level protocol buffer stores the entire entity’s properties as a single serialized data, it means querying only a subset of the entity’s property actually would take an extra post-processing step of filtering the result set and taking only the queried properties. This would entail a performance degradation of the datastore, and is probably why it is not supported by Google at the moment.