最后一天:
课后作业:
1.创建行存表和列存表,并批量插入10万条数据(行存表和列存表数据相同)
需要自己建表!!
CREATE TABLE test_hang (
col1 CHAR(2),
col2 VARCHAR2(40),
col3 NUMBER
);
insert into test_hang select col1, col2, col3 from (select generate_series(1, 100000) as key, repeat(chr(int4(random() * 26) + 65), 2) as col1, repeat(chr(int4(random() * 26) + 65), 30) as col2, (random() * (10^4))::integer as col3);

\d+ test_hang

CREATE TABLE test_lie
(
col1 CHAR(2),
col2 VARCHAR2(40),
col3 NUMBER
)
WITH (ORIENTATION = COLUMN);
insert into test_lie select * from test_hang;

\d+ test_lie;

2.对比行存表和列存表空间大小
\d+

可见行存比列存占用的空间大。
3.对比查询一列和插入一行的速度
explain analyze insert into test_hang values('x', 'zhanghui', '123');
explain analyze insert into test_lie values('x', 'zhanghui', '123');

行存时间比列存小。
4.清理数据
drop table test_hang;

drop table test_lie;

(全文完,谢谢阅读)




