Keeping only the most recent value

All Cloud Bigtable client libraries allow you to read the most recent value at a given row and column by using filters, which is often the best approach. This page describes a strategy that allows you to only keep the most recent value, without needing to set a garbage-collection policy and without needing to use filters when you read the data. Before you read this page, you should read the garbage collection overview.

Timestamp of zero

If you only want to keep one version of a value, and you don't want to wait for garbage collection to remove previous versions, you can set the timestamp to zero every time you write data. In this scenario, new writes immediately hide old ones, so reads will only return a single value for each column. You might still need to wait for a compaction before older writes stop taking up space in the table, depending on how recently the previous data was written.

Pros

  • You don't need to use filters when you read the data, because you can only read the single most recent value of a column.
  • You don't need to set a garbage-collection policy in this case, because you're already deleting old data every time you write over an existing cell.
  • You don't pay storage costs for data that hasn't yet been garbage-collected.

Cons

  • Previous values for a cell are immediately overwritten and cannot be retrieved.
  • Because your timestamps aren't a date and time, you cannot use the cells' timestamps for any other use case, such as determining how old a value is. As a workaround, you can write a real timestamp to a separate column, but this will increase the amount of data you store.

What's next

Oliko tästä sivusta apua? Kerro mielipiteesi

Palautteen aihe:

Tämä sivu
Cloud Bigtable Documentation