hbase-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Josh <jof...@gmail.com>
Subject Efficient time based queries - TIMERANGE or STARTROW/STOPROW?
Date Wed, 12 Apr 2017 17:33:15 GMT

I am just getting started with HBase, and have a question about the
efficiency of timestamp based scans.

My table's row key has structure `uuid#reverse_timestamp` where
reverse_timestamp is (java.lang.Long.MAX_VALUE - time in millis when the
row was written). For a given uuid I want to be able to retrieve the most
recent 10 rows in the table where timestamp is greater than x. It's
possible that a given uuid may have many thousands of rows (with different

I found there are two ways to run my query:
1. use HBase's built in timestamps and scan a time range:
> scan 'mytable', {STARTROW => '647b2194-fbb8-46af-95ba-f498ddc8adcc',
TIMERANGE => [x, current_time], LIMIT => 10}

2. use only my row keys to do the scan, with STARTROW and STOPROW:
scan 'mytable', {STARTROW => '647b2194-fbb8-46af-95ba-f498ddc8adcc',
STOPROW='647b2194-fbb8-46af-95ba-f498ddc8adcc#x', LIMIT => 10}

Both of these seem to work - but is one more efficient that the other?

Thanks for any advice,

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message