Is it possible to store an item in the datastore with 0 index writes?

The number of writes to the datastore required to save the object is 1 + number of indexes

.

What if I update an existing object and the indexed fields are not changed. How many writes will it take? Is it possible to keep an existing item with only 1 write op. if indexes are not affected?

+3


source to share


1 answer


The short answer is no. If you want to search by field, it needs to be indexed and you have to pay for each record. On every record of an object, the whole object is written and the data store doesn't know if you changed the indexed field or not.

If you're worried about cost, you can create fields that are not indexed. Unindexed fields do not add any write operations. However, you cannot search undeclared fields: http://code.google.com/appengine/docs/python/datastore/queries.html#Unindexed_Properties

You can manually set the property to be non-indexed, write the object, and then re-index it. It's almost useless and a lot of effort and probably not what you are looking for. It looks like you want to use the old index, but this method will deflate the index and this particular object will not be indexed (and will not appear in search results), while others are of the same type.



If you have a field that you can write a lot in comparison to the rest of your entity, a task that is worth the cost might be to split that field into your own, non-indexed entity and store its key in the original entity, you will need extra db fetch to get it every time though.

EDIT . This original answer is incorrect. I may have misunderstood the question at the time. While you cannot create a new object with 1 write op, if you are writing an existing object in which the indexed properties do not change, you can actually write with 1 write op.

+3


source







All Articles