002.phoenix-添加表的索引,并激活索引

发布时间 2023-03-22 21:11:33作者: star521

 

 

 

查看是否走索引
explain select id,tenant_id  ,orderid,localorderid,item_code  ,item_name  ,weight,quantity,price,total,sku_id,discountprice,payamount  from  ORDER_CENTER.TR_ORDER_ITEM where TENANT_ID='1323998749169585185'  and orderid in ( '1333369613318286427' ) ;


创建索引
1、建全局索引(异步)
--在phoenix数据库执行:
create index IDX_ORDERITEM_ORDERID_02 on ORDER_CENTER.TR_ORDER_ITEM (TENANT_ID,ORDERID,ID,LOCALORDERID,ITEM_TYPE,ITEM_ID,ITEM_CODE,ITEM_NAME,SKU_ID,CATEGORYID,QUANTITY,WEIGHT,PRICE,TOTAL,CREATEDTIME,PAYAMOUNT) async;
2、激活索引(异步)
--在命令行执行:
./hbase org.apache.phoenix.mapreduce.index.IndexTool --schema ORDER_CENTER  --data-table  TR_ORDER_ITEM --index-table IDX_ORDERITEM_ORDERID_01 --output-path IDX_ORDERITEM_ORDERID_01

字段显示完整的列
!set maxwidth 3000

查看所有的表 
!tables

查看表详情 
 !desc  tablename

 [root@boss  bin]# su hdfs
[hdfs@boss  bin]$ pwd
/usr/hdp/2.6.5.0-292/hbase/bin
[hdfs@boss  bin]$ ./hbase org.apache.phoenix.mapreduce.index.IndexTool --schema ORDER_CENTER  --data-table  TR_ORDER --index-table IDX_ORDER_ORDERID_SHOPCODE --output-path IDX_ORDER_ORDERID_SHOPCODE