Support Questions

Find answers, ask questions, and share your expertise

HBase : how to get max timestamp of a table

avatar
Guru

Hi,

to be able to set timestamp based filters on HBase scan/get commands, I first need to know which timestamps are there.

Therefore my question: how can I select/get/retrieve the max timestamp within a table ? ...preferrably via 'hbase shell'

Finally I want to store this max. timestamp in a file, and use it in next run of manual script to get all HBase rows which have timestamp > previous_max_timestamp

Thanks in advance...

1 REPLY 1

avatar
Super Guru

This isn't answering you question, but this is generally a bad idea. It is not a scalable way to retrieve data in HBase as this is an exhaustive search of your entire HBase table (a full table scan). This should only be used for an infrequently-execute MapReduce job (and even then, with caution as it is an expensive operation and can affect other latencies).

But, if you know what you're doing, see this chapter in the HBase book: https://hbase.apache.org/book.html#cf.keep.deleted

  1. Make sure you create your table to retain more than one version of a cell
  2. Use the RAW => true option on `scan` to see the timestamp field.