hive> select * from student_test where info.age=80 ;
Total MapReduce jobs = 1
Launching Job 1 out of 1
Number of reduce tasks is set to 0 since there's no reduce operator
Starting Job = job_1405418310771_0001, Tracking URL = http://master:8088/proxy/application_1405418310771_0001/
Kill Command = /usr/hadoop/bin/hadoop job -kill job_1405418310771_0001
Hadoop job information for Stage-1: number of mappers: 1; number of reducers: 0
2014-07-15 23:03:29,706 Stage-1 map = 0%, reduce = 0%
2014-07-15 23:04:07,900 Stage-1 map = 100%, reduce = 0%, Cumulative CPU 1.97 sec
2014-07-15 23:04:08,977 Stage-1 map = 100%, reduce = 0%, Cumulative CPU 1.97 sec
MapReduce Total cumulative CPU time: 1 seconds 970 msec
Ended Job = job_1405418310771_0001
MapReduce Jobs Launched:
Job 0: Map: 1 Cumulative CPU: 1.97 sec HDFS Read: 275 HDFS Write: 8 SUCCESS
Total MapReduce CPU Time Spent: 1 seconds 970 msec
OK
4 {"name":"li","age":80}
Time taken: 91.105 seconds, Fetched: 1 row(s)
2.创建索引
hive> create index student_test_index on table student_test(info)
> as 'org.apache.hadoop.hive.ql.index.compact.CompactIndexHandler'
> with deferred rebuild
> IN TABLE student_test_index_table;
复制代码
hive> alter index student_test_index on student_test_index rebuild;
复制代码
3.对比查询
下面用时26.167,比刚开始的 91.105快了很多
hive> select * from student_test where info.age=80;
Total MapReduce jobs = 1
Launching Job 1 out of 1
Number of reduce tasks is set to 0 since there's no reduce operator
Starting Job = job_1405418310771_0003, Tracking URL = http://master:8088/proxy/application_1405418310771_0003/
Kill Command = /usr/hadoop/bin/hadoop job -kill job_1405418310771_0003
Hadoop job information for Stage-1: number of mappers: 1; number of reducers: 0
2014-07-15 23:19:05,465 Stage-1 map = 0%, reduce = 0%
2014-07-15 23:19:17,093 Stage-1 map = 100%, reduce = 0%, Cumulative CPU 1.61 sec
2014-07-15 23:19:18,148 Stage-1 map = 100%, reduce = 0%, Cumulative CPU 1.61 sec
MapReduce Total cumulative CPU time: 1 seconds 610 msec
Ended Job = job_1405418310771_0003
MapReduce Jobs Launched:
Job 0: Map: 1 Cumulative CPU: 1.61 sec HDFS Read: 275 HDFS Write: 8 SUCCESS
Total MapReduce CPU Time Spent: 1 seconds 610 msec
OK
4 {"name":"li","age":80}
Time taken: 26.167 seconds, Fetched: 1 row(s)