root/trunk/extensions/pgsol10.sql

Revision 6, 1.3 kB (checked in by jesus, 7 years ago)

make this right for at least our installation

Line 
1 CREATE TYPE _sol_map_data AS (
2   addr numeric,
3   size bigint,
4   resident bigint,
5   anon bigint,
6   locked bigint,
7   is_readable boolean,
8   is_writable boolean,
9   is_executable boolean,
10   is_shared boolean,
11   is_noreserve boolean,
12   is_reserve1 boolean,
13   map_type varchar,
14   file varchar
15 );
16
17 CREATE OR REPLACE FUNCTION sol_pmap_pid(integer)
18     RETURNS SETOF _sol_map_data
19     AS '/opt/pgsql823/lib/pgsol10', 'sol_pmap_pid'
20     LANGUAGE C IMMUTABLE STRICT;
21
22 CREATE OR REPLACE FUNCTION sol_memsizes_pid(in integer,
23         out file_mem bigint, out shared_mem bigint, out anon_mem bigint,
24         out stack_mem bigint, out heap_mem bigint) LANGUAGE 'SQL' AS $$
25 select
26   sum(CASE WHEN map_type = 'file' THEN size ELSE 0 END)::bigint as file_mem,
27   sum(CASE WHEN map_type = 'shared' THEN size ELSE 0 END)::bigint as shared_mem,
28   sum(CASE WHEN map_type = 'anon' THEN size ELSE 0 END)::bigint as anon_mem,
29   sum(CASE WHEN map_type = 'stack' THEN size ELSE 0 END)::bigint as stack_mem,
30   sum(CASE WHEN map_type = 'heap' THEN size ELSE 0 END)::bigint as heap_mem
31 from sol_pmap_pid($1)
32 $$;
33
34 CREATE OR REPLACE VIEW pg_stat_mem AS
35         SELECT procpid,
36                 (a).file_mem, (a).shared_mem, (a).anon_mem,
37                 (a).stack_mem, (a).heap_mem
38         FROM (SELECT procpid, sol_memsizes_pid(procpid) as a
39                 FROM pg_stat_activity) as foo;
Note: See TracBrowser for help on using the browser.