占用空间对比
最近更新时间: 2024-06-12 15:06:00
UUID表。
postgres=# \d+ t_uuid Table "public.t_uuid" Column | Type | Collation | Nullable | Default | Storage | Stats target | Description --------+------------------------+-----------+----------+--------------------+----------+--------------+------------- f1 | uuid | | not null | uuid_generate_v1() | plain | | f2 | character varying(256) | | | | extended | | Distribute By: SHARD(f2) Location Nodes: ALL DATANODES postgres=# select count(1),pg_size_pretty(pg_table_size('t_uuid')) from t_uuid; count | pg_size_pretty ---------+---------------- 1000000 | 73 MB (1 row)
Serial表。
postgres=# \d+ t_serial Table "public.t_serial" Column | Type | Collation | Nullable | Default | Storage | Stats target | Description --------+------------------------+-----------+----------+--------------------------------------+----------+--------------+------------- id | integer | | not null | nextval('t_serial_id_seq'::regclass) | plain | | f2 | character varying(256) | | | | extended | | Distribute By: SHARD(id) Location Nodes: ALL DATANODES
postgres=# select count(1),pg_size_pretty(pg_table_size('t_serial')) from t_serial;
count | pg_size_pretty
---------+----------------
1000000 | 66 MB
(1 row)
Time: 186.737 ms
- 测试数据对比。
|Uuid/10000条记录|Serial/10000条记录|占用比|
|---------|---------|---------|
|73MB|66MB|1.1倍|