root/trunk/quickstats/quickstats_schema.sql

Revision 28, 1.3 kB (checked in by denish, 5 years ago)

quickstats schema ddl.

Line 
1 --
2 -- PostgreSQL database dump
3 --
4
5 SET client_encoding = 'UTF8';
6 SET standard_conforming_strings = off;
7 SET check_function_bodies = false;
8 SET client_min_messages = warning;
9 SET escape_string_warning = off;
10
11 --
12 -- Name: quickstats; Type: SCHEMA; Schema: -; Owner: postgres
13 --
14
15 CREATE SCHEMA quickstats;
16
17
18 ALTER SCHEMA quickstats OWNER TO postgres;
19
20 SET search_path = quickstats, pg_catalog;
21
22 SET default_tablespace = '';
23
24 SET default_with_oids = false;
25
26 --
27 -- Name: stats; Type: TABLE; Schema: quickstats; Owner: postgres; Tablespace:
28 --
29
30 CREATE TABLE stats (
31     "timestamp" timestamp without time zone DEFAULT now() NOT NULL,
32     ins integer,
33     upd integer,
34     del integer,
35     txn integer,
36     db text
37 );
38
39
40 ALTER TABLE quickstats.stats OWNER TO postgres;
41
42 --
43 -- Name: gather(); Type: FUNCTION; Schema: quickstats; Owner: postgres
44 --
45
46 CREATE FUNCTION gather() RETURNS SETOF void
47     AS $$ insert into quickstats.stats select now(), sum(n_tup_ins) as ins, sum(n_tup_upd) as upd, sum(n_tup_del) as del, (select xact_commit from pg_catalog.pg_
48 stat_database where datname=(select current_database())) as xact_commit, current_database() from pg_stat_all_tables $$
49     LANGUAGE sql;
50
51
52 ALTER FUNCTION quickstats.gather() OWNER TO postgres;
53
54 --
55 -- PostgreSQL database dump complete
56 --
Note: See TracBrowser for help on using the browser.