Google Cloud Datastore avoid entity overhead when fetching

140 views Asked by At

Is it possible to avoid the entity overhead when fetching data in the cloud datastore ? Ideally I'd love to have SQL-like results : simple arrays/objects with key:values instead of

{
 "batch": {
  "entityResultType": "FULL",
  "entityResults": [
   {
    "entity": {
     "key": {
      "partitionId": {
       "datasetId": "e~******************"
      },
      "path": [
       {
        "kind": "Answer",
        "id": "*******************"
       }
      ]
     },
     "properties": {
      "value": {
       "stringValue": "12",
       "indexed": false
      },
      "question": {
       "integerValue": "120"
      }
     }
    }
   }
  ],
  "endCursor": "********************************************",
  "moreResults": "MORE_RESULTS_AFTER_LIMIT",
  "skippedResults": null
 }
}

which has just too much overhead for me (I plan on running queries over thousands of entities). I just couldn't find in the docs if that's possible or not.

1

There are 1 answers

2
Ed Davisson On

You can use projection queries to query for specific entity properties.

In your example, you could use a projection query to avoid returning the entity's key in the query results.

The other fields are part of the API's data representation and are required to be returned, however, many of them (e.g. endCursor) are only returned once per query batch, so the overhead is low when there are many results.