基于Phoenix对HBase建索引
Posted ratels
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了基于Phoenix对HBase建索引相关的知识,希望对你有一定的参考价值。
参考:
在DBeaver中执行下列语句:
select * from ASSET_NORMAL WHERE ASSET_ID=‘19-1151444153020846080‘;
返回信息:
3d8f2cf978094a47b2f24dea58fa697c 19-1151444153020846080 电脑 1001005 信息设备 1001005002 ……
如下:
在DBeaver中执行下列语句:
select count(*) from ASSET_NORMAL;
返回信息:
10,614
如下:
在DBeaver中执行下列语句:
explain select count(*) from ASSET_NORMAL;
返回信息:
CLIENT 1-CHUNK PARALLEL 1-WAY FULL SCAN OVER IDX_ASSET_NORMAL SERVER FILTER BY FIRST KEY ONLY SERVER AGGREGATE INTO SINGLE ROW CLIENT 200 ROW LIMIT
如下:
在DBeaver中执行下列语句:
explain select * from ASSET_NORMAL WHERE ASSET_ID=‘19-1151444153020846080‘;
返回信息:
CLIENT 1-CHUNK 200 ROWS 177000 BYTES SERIAL 1-WAY ROUND ROBIN RANGE SCAN OVER IDX_ASSET_NORMAL [‘19-1151444153020846080‘] 177000 200 0 SERVER FILTER BY FIRST KEY ONLY 177000 200 0 SERVER 200 ROW LIMIT 177000 200 0 CLIENT 200 ROW LIMIT 177000 200 0
如下:
直接通过Bash进行操作,执行下列语句:
select count(*) from ASSET_NORMAL;
耗时0.071s,返回如下信息:
0: jdbc:phoenix:node3:2181:/hbase> select count(*) from ASSET_NORMAL; +-----------+ | COUNT(1) | +-----------+ | 11286 | +-----------+ 1 row selected (0.071 seconds)
执行下列语句:
explain select count(*) from ASSET_NORMAL;
耗时0.03s,返回如下信息:
0: jdbc:phoenix:node3:2181:/hbase> explain select count(*) from ASSET_NORMAL; +----------------------------------------------------------------+-----------------+----------------+--------------+ | PLAN | EST_BYTES_READ | EST_ROWS_READ | EST_INFO_TS | +----------------------------------------------------------------+-----------------+----------------+--------------+ | CLIENT 1-CHUNK PARALLEL 1-WAY FULL SCAN OVER IDX_ASSET_NORMAL | null | null | null | | SERVER FILTER BY FIRST KEY ONLY | null | null | null | | SERVER AGGREGATE INTO SINGLE ROW | null | null | null | +----------------------------------------------------------------+-----------------+----------------+--------------+ 3 rows selected (0.03 seconds)
执行下列语句:
select * from ASSET_NORMAL WHERE ASSET_ID=‘19-1151444153020846080‘;
耗时0.359s,返回如下信息:
0: jdbc:phoenix:node3:2181:/hbase> select * from ASSET_NORMAL WHERE ASSET_ID=‘19-1151444153020846080‘; +-----------------------------------+-------------------------+-------------+------------------------+--------------------------+----------------+ | ID | ASSET_ID | ASSET_NAME | ASSET_FIRST_DEGREE_ID | ASSET_FIRST_DEGREE_NAME | ASSET_SECOND_D | +-----------------------------------+-------------------------+-------------+------------------------+--------------------------+----------------+ | 3d8f2cf978094a47b2f24dea58fa697c | 19-1151444153020846080 | 电脑 | 1001005 | 信息设备 | 1001005002 | +-----------------------------------+-------------------------+-------------+------------------------+--------------------------+----------------+ 1 row selected (0.359 seconds)
执行下列语句:
explain select * from ASSET_NORMAL WHERE ASSET_ID=‘19-1151444153020846080‘;
耗时0.025s,返回如下信息:
0: jdbc:phoenix:node3:2181:/hbase> explain select * from ASSET_NORMAL WHERE ASSET_ID=‘19-1151444153020846080‘; +--------------------------------------------------------------------------------------------------------+-----------------+----------------+----+ | PLAN | EST_BYTES_READ | EST_ROWS_READ | ES | +--------------------------------------------------------------------------------------------------------+-----------------+----------------+----+ | CLIENT 1-CHUNK PARALLEL 1-WAY ROUND ROBIN RANGE SCAN OVER IDX_ASSET_NORMAL [‘19-1151444153020846080‘] | null | null | nu | | SERVER FILTER BY FIRST KEY ONLY | null | null | nu | +--------------------------------------------------------------------------------------------------------+-----------------+----------------+----+ 2 rows selected (0.025 seconds)
如下:
以上是关于基于Phoenix对HBase建索引的主要内容,如果未能解决你的问题,请参考以下文章
phoenix连接hbase数据库,创建二级索引报错:Error: org.apache.phoenix.exception.PhoenixIOException: Failed after atte