Исходный код СУБД 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
--
-- src/test/performance/cfs/datashape_text.sql
--
-- Phase 13 / A13.2 -- data-shape benchmark: highly repetitive text.
--
-- The classic best case for page-level compression: long runs of the same
-- token.  Shows how close CFS gets to the codec's own stream ratio.
--
--   psql -v rows=5000 -f datashape_text.sql
 
DROP TABLE IF EXISTS ds_text_plain;
DROP TABLE IF EXISTS ds_text_cfs;
 
CREATE TABLE ds_text_plain (id int primary key, payload text);
SELECT format('CREATE TABLE ds_text_cfs (id int primary key, payload text) WITH (algorithm=%L)', :'algo')\gexec
 
INSERT INTO ds_text_plain SELECT g, repeat('ab', 400) FROM generate_series(1, :rows) g;
INSERT INTO ds_text_cfs   SELECT * FROM ds_text_plain;
CHECKPOINT;
 
SELECT 'ds_text' AS shape,
       pg_size_pretty(pg_total_relation_size('ds_text_plain')) AS plain_size,
       pg_size_pretty(pg_total_relation_size('ds_text_cfs'))  AS cfs_size,
       round(pg_total_relation_size('ds_text_plain')::numeric /
             NULLIF(pg_total_relation_size('ds_text_cfs'), 0), 2) AS ratio;