Updated on 2026-06-29 GMT+08:00

HBase Global Secondary Index Sample Program Development Roadmap

HBase allows you to use global secondary indexes to accelerate conditional queries. This case shows you how to manage and use global secondary indexes.

This sample program applies only to MRS 3.3.0 and later versions.

Scenario

Assume the application you develop needs to record user information and addresses. The following table lists the recorded data.

Table 1 User information list

id

name

age

address

1

Zhang

20

CityA

2

Li

30

CityB

3

Wang

35

CityC

Data Preparation

Proper design of a table structure, RowKeys, and column names enable you to make full use of HBase advantages. The global secondary index is used in the scan condition query scenario. The query is performed by the index table. You do not need to pay attention to the rowkey of the user table. In this example, the rowkey format of the user table is "r1", "r2", "r3".... All columns are stored in the info column family.

Sample Description

The example introduces the creation, status modification, deletion, and query of global secondary indexes.