5
votes

I thinking about great improvement of Azure Table Storage. Is it possible to submit query to Table Storage with specific operation such as "increment entity field [name] by [value] where [PartitionKey=somestingPK] and [RowKey=somethingRK]"?

@smarx is this feature will be available?

3

3 Answers

5
votes

You can accomplish this with either Table or Page storage with ETAG tracking enabled. I use this technique to create an Identity value for each entry in Azure Table. The idea goes like this:

  • Read the value from the Page Blob, leave ETAG tracking enabled

  • Increment the retrieved value

  • POST the retrieved value, and if there is an ETAG conflict, retry the whole operation again fresh. Perhaps use an exponential backoff algorithm here to prevent overloading the target container or partition.

1
votes

Yes, this is possible - but perhaps not exactly the way you are thinking. You are looking for the MERGE operation. To use it, you must know the entity (i.e the partition key and rowkey of the entity) you are targeting. You do not have to retrieve the entity to update it, but you must specifically address each entity either per REST call or using the batch capabilities (which has some restrictions).

0
votes

This is similar to UPDATE query of MySQL and currently is not possible to perform in Azure Table Storage. Not sure if this is possible to achieve in such a database type, since you have first to get the whole entity, update the fields you want, and store back to the database.