Hive_Hive的数据模型_分区表
Hive的数据模型之分区表
准备数据表:
create table sampledata
(sid int, sname string, gender string, language int, math int, english int)
row format delimited fields terminated by ',' stored as textfile;
准备文本数据:
sampledata.txt
1,Tom,M,60,80,96
2,Mary,F,11,22,33
3,Jerry,M,90,11,23
4,Rose,M,78,77,76
5,Mike,F,99,98,98
将文本数据插入到数据表:
hive> load data local inpath '/root/pl62716/hive/sampledata.txt' into table sampledata;
-partition对应于数据库中的Partition 列的密集索引
-在Hive中,表中的一个Partition对应于表下的一个目录,所有的Partition的数据都存储在对应的目录中。
创建分区表:
create table partition_table
(sid int, sname string)
partitioned by (gender string)
row format delimited fields terminated by ',';
向分区表中插入数据:
hive> insert into table partition_table partition(gender='M') select sid, sname from sampledata where gender='M';
hive> insert into table partition_table partition(gender='F') select sid, sname from sampledata where gender='F';
从内部表解析比从分区表解析效率低:
(1)内部表:
hive> explain select * from sampledata where gender='M';
OK
STAGE DEPENDENCIES:
Stage-0 is a root stage STAGE PLANS:
Stage: Stage-0
Fetch Operator
limit: -1
Processor Tree:
TableScan
alias: sampledata
Statistics: Num rows: 1 Data size: 90 Basic stats: COMPLETE Column stats: NONE
Filter Operator
predicate: (gender = 'M') (type: boolean)
Statistics: Num rows: 1 Data size: 90 Basic stats: COMPLETE Column stats: NONE
Select Operator
expressions: sid (type: int), sname (type: string), 'M' (type: string), language (type: int), math (type: int), english (type: int)
outputColumnNames: _col0, _col1, _col2, _col3, _col4, _col5
Statistics: Num rows: 1 Data size: 90 Basic stats: COMPLETE Column stats: NONE
ListSink Time taken: 0.046 seconds, Fetched: 20 row(s)
(2)分区表:
hive> explain select * from partition_table where gender='M';
OK
STAGE DEPENDENCIES:
Stage-0 is a root stage STAGE PLANS:
Stage: Stage-0
Fetch Operator
limit: -1
Processor Tree:
TableScan
alias: partition_table
Statistics: Num rows: 2 Data size: 13 Basic stats: COMPLETE Column stats: NONE
Select Operator
expressions: sid (type: int), sname (type: string), 'M' (type: string)
outputColumnNames: _col0, _col1, _col2
Statistics: Num rows: 2 Data size: 13 Basic stats: COMPLETE Column stats: NONE
ListSink Time taken: 0.187 seconds, Fetched: 17 row(s)
Hive_Hive的数据模型_分区表的更多相关文章
- Hive_Hive的数据模型_汇总
体系结构: 元数据 /HQL的执行安装: 嵌入 /远程 /本地管理: CLI /web界面 /远程服务数据类型: 基本 /复杂 /时间数据模型: 数据存储 /内部表 /分区表 /外部表 /桶表 /视图 ...
- Hive_Hive的数据模型_数据存储
Hive的数据模型_数据存储 web管理工具察看HDFS文件系统:http://<IP>:50070/ 基于HDFS没有专门的数据存储格式,默认使用制表符存储结构主要包括:数据库,文件,表 ...
- Hive_Hive的数据模型_内部表
Hive的数据模型_内部表 - 与数据库中的Table在概念上是类似.- 每一个Table在Hive中都有一个相应的目录存储数据.- 所有的Table数据(不包括External Table)都保存在 ...
- Hive_Hive的数据模型_外部表
Hive的数据模型之外部表 外部表(External Table)- 指向已经在HDFS中存在的数据,可以创建Partition- 它和内部表在元数据的组织上是相同的,而实际数据的存储则有较大的差异. ...
- Hive_Hive的数据模型_视图
- 视图是一种虚表,是一个逻辑概念:可以跨越多张表- 视图建立在已有表的基础上,视图赖以建立的这些表称为基表.- 视图可以简化复杂的查询. 创建视图 create view viewName as s ...
- Hive_Hive的数据模型_桶表
对数据进行HASH运算,放在不同文件中,降低热块,提高查询速度. 例如:根据sname进行hash运算存入5个桶中. create table bucket_table(sid int, sname ...
- 21Mybatis_订单商品数据模型_一对多查询——resultMap方式
这篇文章延续订单商品数据模型,这张讲述的是一对多的查询.(用resultMap) 给出几张表的内容: User表:
- 20Mybatis_订单商品数据模型_一对一查询——resultType和resultMap两种方式以及两种方式的总结
上一篇文章分析了数据模型,这篇文章就给出一个需求,这个需求是一对一查询,并完成这个需求. ------------------------------------------------------- ...
- 22Mybatis_订单商品数据模型_多对多查询以及对多对多查询的总结
之前讲了一对一,一对多查询,这篇文章讲的是多对多. 先给出需求:查询用户及用户购买商品信息. 我们由之前的文章知道,这个需求是多对多的. 还是那个终止我们的mybatis所做的不管是之前的一对一还是一 ...
随机推荐
- str_2.判断两个字符串是否互为旋转词
1. 字符串str的前面任意部分挪到后面形成的字符串叫做字符串str的旋转词 $str1 = "2ab1"; $str2 = "ab12"; $ret = is ...
- 基类的两个派生类再派生一个派生类 用virtual避免二义性
class vehicle{ int MaxSpeed; int Weight;public: vehicle(int maxspeed, int weight) :MaxSpeed(maxspeed ...
- MFC模态对话框程序不响应OnIdle
从代码分析原因吧: OnIdle函数在MFC的CWinThread::Run函数中被调用,如下 // main running routine until thread exits int CWinT ...
- 生成0-42之间的7个不重复的int值
public static void main(String[] args) { //set集合存储不重复无序的值 Set<Integer> set = new HashSet<In ...
- ACM学习历程—HDU 5326 Work(树形递推)
Problem Description It’s an interesting experience to move from ICPC to work, end my college life an ...
- RT-Thread的线程(任务)处理 rt_thread_create/rt_thread_init区别
RT-Thread中使用线程这个概念,而不是任务.两者相似,我在这里把他的线程当作任务来理解了 1.任务处理: 动态任务相关API 创建任务:rt_thread_create函数,创建任务之后会返回r ...
- WPF win7+vs2010开发的打印功能,怎么在XP系统上无法打印
在wpf 中打印功能很强大,但最近是在win7上可以但是布置到xp上就不可以了,查了好多资料终于知道怎么回事了原来xp里没有.net framework3.5 安装一个就OK了要先安装4.0.
- python的logging模块详细使用demo
import logging import os from logging import handlers from datetime import datetime class MyLog(): d ...
- ASPNET session客户端与服务…
除非程序通知服务器删除一个session,否则服务器会一直保留,程序一般都是在用户做log off的时候发个指令去删除session.然而浏览器从来不会主动在关闭之前通知服务器它将要关闭,因此服务器根 ...
- day8 服务器
XML约束 XML约束要求:大家能够看懂约束内容,根据约束内容写出符合规则的xml文件. 2.1 引入 XML语法: 规范的xml文件的基本编写规则.(由w3c组织制定的) XML约束: 规范XML文 ...