当前位置:网站首页>Talk about row storage and column storage of database
Talk about row storage and column storage of database
2022-07-28 07:59:00 【Architect community】
original text :my.oschina.net/gaussdb/blog/5544252
Comparison of storage methods

Comparison of advantages and disadvantages
Bank deposit | Column to save | |
advantage | The data is kept together .INSERT/UPDATE Easy to . |
|
shortcoming | choice (Selection) Even if only a few columns are involved , All the data will also be read . |
|
Applicable scenario |
|
|
Row storage and column storage experiments
Create row save table custom1 And inventory table custom2 , Insert 50 Ten thousand records .
openGauss=# create table custom1 (id integer,name varchar2(20));CREATE TABLEopenGauss=# create table custom2 (id integer,name varchar2(20)) with (orientation = column);CREATE TABLEopenGauss=# insert into custom1 select n,'testtt'||n from generate_series(1,500000) n;INSERT 0 500000openGauss=# insert into custom2 select * from custom1;INSERT 0 500000
openGauss=# \d+List of relationsSchema | Name | Type | Owner | Size | Storage | Description--------+------------+-------+-------+------------+--------------------------------------+-------------public | custom1 | table | omm | 24 MB | {orientation=row,compression=no} |public | custom2 | table | omm | 3104 kB | {orientation=column,compression=low} |
openGauss=# explain analyze insert into custom1 values(1,'zhang3');QUERY PLAN-----------------------------------------------------------------------------------------------[Bypass]Insert on custom1 (cost=0.00..0.01 rows=1 width=0) (actual time=0.059..0.060 rows=1 loops=1)-> Result (cost=0.00..0.01 rows=1 width=0) (actual time=0.001..0.001 rows=1 loops=1)Total runtime: 0.135 ms(4 rows)openGauss=# explain analyze insert into custom2 values(1,'zhang3');QUERY PLAN-----------------------------------------------------------------------------------------------Insert on custom2 (cost=0.00..0.01 rows=1 width=0) (actual time=0.119..0.120 rows=1 loops=1)-> Result (cost=0.00..0.01 rows=1 width=0) (actual time=0.001..0.002 rows=1 loops=1)Total runtime: 0.207 ms(3 rows)
Finally, delete the test table .
openGauss=# drop table custom1;DROP TABLEopenGauss=#drop table custom2;DROP TABLE
Choose suggestions
Update frequency : If the data is updated frequently , Select row save table .
Insertion frequency : Frequent small insertions , Select row save table . Insert a large amount of data at one time , Select the column save table .
The column number of the table : In general , If the table has more fields, that is, more columns ( A wide watch ), When there are not many columns involved in the query , Suitable for column storage . If the number of fields in the table is small , Query most fields , It is better to select row storage .
Number of columns to query : If every query , Only a few of the tables are involved (<50% The total number of columns ) Several columns , Select the column save table .( Don't ask what the rest of the columns are for , What Party A says is useful is useful .)
compression ratio : The compression ratio of column saving table is higher than that of row saving table . But high compression rates consume more CPU resources .
matters needing attention
边栏推荐
- MySQL: what is the difference between like and regexp operations?
- protobuf 基本语法总结
- EMC设计攻略 —时钟
- 非关系型数据库之Redis【redis安装】
- Opencv's practical learning of credit card recognition (4)
- DNA修饰金属铑Rh纳米颗粒RhNPS-DNA(DNA修饰贵金属纳米颗粒)
- Summary of RFID radiation test
- win系统添加打印机
- Some experience of gd32 using Hal Library of ST and Gd official library
- 【干货】32个EMC标准电路分享!
猜你喜欢
![[dry goods] 32 EMC standard circuits are shared!](/img/51/cff9dd7e033ca2df917307e9fe38ff.jpg)
[dry goods] 32 EMC standard circuits are shared!

EMC's "don't come back until you rectify"

【17】 Establish data path (upper): instruction + operation =cpu

谈谈DOM0,DOM1,DOM2,DOM3

非关系型数据库之Redis【redis安装】

快速搭建DMHS DM之间双向同步

XSS知识点和20字符短域名绕过

华为高级工程师---BGP路由过滤及社团属性

Qt使用信号量控制线程(QSemaphore)

EMC rectification method set
随机推荐
【google】解决google浏览器不弹出账号密码保存框且无法保存登录信息问题
node(一)
近红外二区AgzS量子点包裹脱氧核糖核酸DNA|DNA-AgzSQDs(齐岳)
Method of hiding scroll bar in wechat applet
Fxksmdb.exe process description
[dry goods] 32 EMC standard circuits are shared!
0727~ sorting out interview questions
Elaborate on common mode interference and differential mode interference
【300+精选大厂面试题持续分享】大数据运维尖刀面试题专栏(八)
Parse tree structure JS
Mysql, how can we get the number of rows affected by the query?
The penultimate node in the linked list - Double finger
Elaborate on common mode interference and differential mode interference
mysql:LIKE和REGEXP操作有什么区别?
ArcGIS JS自定义Accessor,并通过watchUtils相关方法watch属性
Copper indium sulfide CuInSe2 quantum dots modified DNA (deoxyribonucleic acid) DNA cuinse2qds (Qiyue)
磁环选型攻略及EMC整改技巧
DNA修饰贵金属纳米颗粒|DNA脱氧核糖核酸修饰金属钯Pd纳米颗粒PdNPS-DNA
ArcGIS JS 地图内外网环境判断问题
(daily question) - the longest substring without repeated characters