Исходный код СУБД 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
--
-- src/test/performance/cfs/cfs_perf_report.sql
--
-- Run after a pgbench pass to emit one row per table with the CFS accounting
-- that the harness report is built from:
--
--   table name, logical size, physical (compressed) size, compression ratio,
--   dead bytes / dead pages, sidecar file sizes (.cfp/.cfsmap/.cfsjrn).
--
-- pg_stat_cfs only lists CFS relations, so plain tables are reported from
-- pg_total_relation_size().
 
\pset format aligned
\pset null '(null)'
 
SELECT
    relname,
    pg_size_pretty(logical_size)               AS logical_size,
    pg_size_pretty(physical_size)              AS physical_size,
    round(compression_ratio::numeric, 2)       AS compression_ratio,
    dead_pages,
    pg_size_pretty(dead_bytes)                 AS dead_bytes,
    to_char(last_compaction, 'YYYY-MM-DD HH24:MI:SS') AS last_compaction
FROM pg_stat_cfs
ORDER BY relname;
 
-- Physical on-disk footprint, including the CFS sidecar files (.cfp/.cfsmap/
-- .cfsjrn) which live next to the main fork and are accounted for by
-- pg_total_relation_size() (Stage 12).
SELECT
    relname,
    pg_size_pretty(pg_relation_size(relid))    AS main_fork,
    pg_size_pretty(pg_total_relation_size(relid)) AS total_incl_sidecars
FROM pg_stat_cfs
ORDER BY relname;