Hbase Learning (18) hbase rowkey Design 1

Source: Internet
Author: User
Hbase's three-dimensional ordered storage consists of rowkey, column key (columnfamily + qualifier), and timestamp.

1. rowkey. We know that rowkey is the primary key of the row, and hbase can only use a rowkey or a rowkey range, that is, scan, to find data. Therefore, the design of rowkey is crucial and affects the query efficiency at your application layer. We know that rowkey is ordered alphabetically. The stored bytecode and dictionary sorting, we know that if it is the denominator, It is the alphabetic order. For example, there are two rowkeys, rowkey1: aaa222, rowkey2: bbb111, then, rowkey1 is placed before rowkey2, because in the dictionary, A is placed before B. If rowkey2 is set to a first, it is compared based on the second. If it is set to the same, the third is compared, the same is true. This is an understanding. When we query by rowkey range, we generally know startrowkey. If we pass scan to only start with startrowkey: D, the query results are all larger than that of D. Instead, we only need data starting with D, which is restricted by endrowkey. We can set the endrowkey to start with "D", followed by your rowkey combination. Generally, it is bigger than startkey. For example, if rowkey is designed as user ID-date, the startkey is 3231-20121212 and the endkey is 3231 + 201213, so what you found is the data of 3231 million users on 20121212 day.

2. Column key

Column key is the second dimension. After the data is sorted by rowkey dictionary, if rowkey is the same, the data is sorted by column key and also by dictionary.
We should learn to use this when designing tables. For example, our inbox. We sometimes need to sort by topic, so we can set the topic as our column key, that is, the design as columnfamily + topic.

3. Timestamp

Timestamp: The timestamp, which is in the descending order. That is, the latest data is placed at the top. This is nothing to say. There are many other blogs on the Internet.

In this article, we will briefly describe the dictionary sorting of rowkey (three-dimensional order)

Hbase Learning (18) hbase rowkey Design 1

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.