時間:2024-02-04 13:45作者:下載吧人氣:23
由于最近在做超大表的性能測試,在該過程中發現了無序uuid做主鍵對表插入性能有一定影響。結合實際情況發現當表的數據量越大,對表插入性能的影響也就越大。
PostgreSQL創建插入腳本,測試各種情況的tps。
數據庫版本:PostgreSQL 10.4 (ArteryBase 5.0.0, Thunisoft)
操作系統配置:CentOS Linux release 7 ,32GB內存,8 cpu
測試參數:pgbench -M prepared -r -n -j 8 -c 8 -T 60 -f /opt/thunisoft/pgbench_uuid_v4.sql -U sa pgbenchdb
空表,1000w數據,5000w數據,一億數據的各種主鍵測試。
測試無序的uuid,有序的uuid,序列,有普通btree,有唯一索引和沒有主鍵的情況
1.創建表
–無序的uuid
pgbenchdb=# create table test_uuid_v4(id char(32) primary key);
CREATE TABLE
–有序的uuid
pgbenchdb=# create table test_time_nextval(id char(32) primary key);
CREATE TABLE
–遞增序列
pgbenchdb=# create table test_seq_bigint(id int8 primary key);
CREATE TABLE
–創建序列
create sequence test_seq start with 1 ;
網友評論