Исходный код СУБД RuDB — свободной СУБД с открытым исходным кодом на базе PostgreSQL
rudb
2 days ago bd039d1e92813358c5c5a1e346b49074baf513f2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
--
-- src/test/performance/cfs/cfs_perf_setup.sql
--
-- Shared schema for the CFS pgbench performance harness
-- (see pgbench_readonly.sh / pgbench_readwrite.sh).  Creates four identical
-- tables populated with the same compressible workload, differing only in
-- their CFS storage policy:
--
--   perf_plain        no compression (baseline)
--   perf_lz4_1        CFS, lz4,  level 1
--   perf_zstd_1       CFS, zstd, level 1
--   perf_zstd_3       CFS, zstd, level 3
--
-- The data shape is deliberately repetitive text so that compression yields a
-- measurable ratio; tune :rows and :payload_len from the harness scripts.
 
-- Drop previous run if the script is re-run idempotently.
DROP TABLE IF EXISTS perf_plain;
DROP TABLE IF EXISTS perf_lz4_1;
DROP TABLE IF EXISTS perf_zstd_1;
DROP TABLE IF EXISTS perf_zstd_3;
 
CREATE TABLE perf_plain   (id int primary key, payload text);
CREATE TABLE perf_lz4_1   (id int primary key, payload text) WITH (algorithm = 'lz4',  level = 1);
CREATE TABLE perf_zstd_1  (id int primary key, payload text) WITH (algorithm = 'zstd', level = 1);
CREATE TABLE perf_zstd_3  (id int primary key, payload text) WITH (algorithm = 'zstd', level = 3);
 
-- Identical payload for every table: a moderately compressible text blob.
INSERT INTO perf_plain  SELECT g, repeat(md5(g::text), :payload_len / 32) FROM generate_series(1, :rows) g;
INSERT INTO perf_lz4_1  SELECT * FROM perf_plain;
INSERT INTO perf_zstd_1 SELECT * FROM perf_plain;
INSERT INTO perf_zstd_3 SELECT * FROM perf_plain;
 
-- Make sure every page is on disk in its final (compressed) form.
CHECKPOINT;
ANALYZE;