Command like SQL LIMIT in HBase

Mohammad picture Mohammad · Dec 22, 2012 · Viewed 59.2k times · Source

Does HBase have any command that works like SQL LIMIT query?

I can do it by setStart and setEnd, but I do not want to iterate all rows.

Answer

th30z picture th30z · Dec 22, 2012

From the HBase shell you can use LIMIT:

hbase> scan 'test-table', {'LIMIT' => 5}

From the Java API you can use Scan.setMaxResultSize(N) or scan.setMaxResultsPerColumnFamily(N).