OSDN Git Service

1.3.0
[pgdbmsstats/pg_dbms_stats.git] / output / ut_imp_exp-9.2.source
1 \pset null '(null)'
2 CREATE TABLE s0.st3();
3 /*
4  * No.16-1 export_plain_stats.sql.sample
5  */
6 -- No.16-1-1
7 ANALYZE;
8 DELETE FROM dbms_stats._column_stats_locked;
9 DELETE FROM dbms_stats._relation_stats_locked;
10 SELECT dbms_stats.lock_database_stats();
11  lock_database_stats 
12 ---------------------
13  pt0
14  pt0_idx
15  st0
16  st0_idx
17  st1
18  s0.st0
19  s0.st0_idx
20  s0.st1
21  s0.st1_idx
22  s0.st2
23  s0.st2_idx
24  s0.sft0
25  st1_idx
26  st1_exp
27  s1.st0
28  s0.st3
29 (16 rows)
30
31 UPDATE dbms_stats._relation_stats_locked
32    SET (relpages, reltuples, relallvisible, curpages) = (0,0,0,0);
33 UPDATE dbms_stats._column_stats_locked SET
34     stanullfrac = -staattnum,
35     stawidth = -staattnum,
36     stadistinct = -staattnum,
37     stakind1 = 2,
38     stakind2 = 3,
39     stakind3 = 4,
40     stakind4 = 1,
41     stakind5 = 5,
42     staop1 = 22,
43     staop2 = 23,
44     staop3 = 24,
45     staop4 = 21,
46     staop5 = 25,
47     stanumbers1 = ARRAY[-staattnum,22],
48     stanumbers2 = ARRAY[-staattnum,23],
49     stanumbers3 = ARRAY[-staattnum,24],
50     stanumbers4 = ARRAY[-staattnum,21],
51     stanumbers5 = ARRAY[-staattnum,25],
52     stavalues1 = stavalues3,
53     stavalues2 = stavalues2,
54     stavalues3 = stavalues1,
55     stavalues4 = stavalues4,
56     stavalues5 = stavalues5;
57 \i export_plain_stats.sql.sample
58 /*
59  * If you want the statistics of per-relation or per-column, please modify
60  * nspname, relname, and attname in 'WHERE' clause.
61  */
62 BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE;
63 /*
64  * If you want to chage the output file name, please modify the following name.
65  */
66 \o export_stats.dmp
67 COPY (SELECT n2.nspname,
68              c.relname,
69              c.relpages,
70              c.reltuples,
71              c.relallvisible,
72              (pg_relation_size(c.oid) / current_setting('block_size')::int4)::int4
73                  AS curpages,
74              pg_catalog.pg_stat_get_last_analyze_time(c.oid)
75                  AS last_analyze,
76              pg_catalog.pg_stat_get_last_autoanalyze_time(c.oid)
77                  AS last_autoanalyze,
78              COALESCE(a.attname, ''),
79              n1.nspname AS schemaname_of_atttype,
80              t.typname,
81              a.atttypmod,
82              s.stainherit,
83              s.stanullfrac,
84              s.stawidth,
85              s.stadistinct,
86              s.stakind1,
87              s.stakind2,
88              s.stakind3,
89              s.stakind4,
90              s.stakind5,
91              s.staop1,
92              s.staop2,
93              s.staop3,
94              s.staop4,
95              s.staop5,
96              s.stanumbers1,
97              s.stanumbers2,
98              s.stanumbers3,
99              s.stanumbers4,
100              s.stanumbers5,
101              s.stavalues1,
102              s.stavalues2,
103              s.stavalues3,
104              s.stavalues4,
105              s.stavalues5
106         FROM pg_statistic s
107         JOIN pg_attribute a
108           ON (s.starelid = a.attrelid AND s.staattnum = a.attnum)
109         JOIN pg_type t
110           ON a.atttypid = t.oid
111         JOIN pg_namespace n1
112           ON t.typnamespace = n1.oid
113        RIGHT JOIN pg_catalog.pg_class c
114           ON s.starelid = c.oid
115         JOIN pg_catalog.pg_namespace n2
116           ON c.relnamespace = n2.oid
117        WHERE c.relkind IN ('r', 'i', 'f')
118          AND NOT n2.nspname IN ('pg_catalog',
119                                 'pg_toast',
120                                 'information_schema',
121                                 'dbms_stats')
122         -- AND n2.nspname = 'public'
123         -- AND c.relname = 'test'
124         -- AND a.attname = 'id'
125        ORDER BY starelid, staattnum)
126 TO STDOUT
127 (FORMAT 'binary');
128 \o
129 COMMIT;
130 COPY dbms_stats.work FROM '@abs_srcdir@/export_stats.dmp' (FORMAT 'binary');
131 SELECT * FROM work_v;
132  nspname | relname | relpages | reltuples | relallvisible | curpages | attname | nspname_of_typename | typname | atttypmod | stainherit | stanullfrac | stawidth | stadistinct | stakind1 | stakind2 | stakind3 | stakind4 | stakind5 | staop1 | staop2 | staop3 | staop4 | staop5 |      stanumbers1       | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 |    stavalues1    | stavalues2 | stavalues3 | stavalues4 | stavalues5 
133 ---------+---------+----------+-----------+---------------+----------+---------+---------------------+---------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+------------------------+-------------+-------------+-------------+-------------+------------------+------------+------------+------------+------------
134  public  | pt0     |        0 |         0 |             0 |        0 |         | (null)              | (null)  |    (null) | (null)     |      (null) |   (null) |      (null) |   (null) |   (null) |   (null) |   (null) |   (null) | (null) | (null) | (null) | (null) | (null) | (null)                 | (null)      | (null)      | (null)      | (null)      | (null)           | (null)     | (null)     | (null)     | (null)
135  public  | pt0_idx |        2 |         0 |             0 |        2 |         | (null)              | (null)  |    (null) | (null)     |      (null) |   (null) |      (null) |   (null) |   (null) |   (null) |   (null) |   (null) | (null) | (null) | (null) | (null) | (null) | (null)                 | (null)      | (null)      | (null)      | (null)      | (null)           | (null)     | (null)     | (null)     | (null)
136  public  | st0     |        1 |         2 |             1 |        1 | id      | pg_catalog          | int4    |        -1 | f          |           0 |        4 |          -1 |        2 |        3 |        0 |        0 |        0 |     97 |     97 |      0 |      0 |      0 | (null)                 | {1}         | (null)      | (null)      | (null)      | {1,2}            | (null)     | (null)     | (null)     | (null)
137  public  | st0     |        1 |         2 |             1 |        1 | name    | pg_catalog          | bpchar  |         9 | f          |           0 |        6 |        -0.5 |        1 |        3 |        0 |        0 |        0 |   1054 |   1058 |      0 |      0 |      0 | {1}                    | {1}         | (null)      | (null)      | (null)      | {"test "}        | (null)     | (null)     | (null)     | (null)
138  public  | st0_idx |        2 |         2 |             0 |        2 |         | (null)              | (null)  |    (null) | (null)     |      (null) |   (null) |      (null) |   (null) |   (null) |   (null) |   (null) |   (null) | (null) | (null) | (null) | (null) | (null) | (null)                 | (null)      | (null)      | (null)      | (null)      | (null)           | (null)     | (null)     | (null)     | (null)
139  public  | st1     |       45 |     10000 |            45 |       45 | str     | pg_catalog          | text    |        -1 | f          |           0 |        2 |           3 |        1 |        3 |        0 |        0 |        0 |     98 |    664 |      0 |      0 |      0 | {0.3334,0.3333,0.3333} | {0.3332}    | (null)      | (null)      | (null)      | {1,0,2}          | (null)     | (null)     | (null)     | (null)
140  public  | st1     |       45 |     10000 |            45 |       45 | val     | pg_catalog          | int4    |        -1 | f          |           0 |        4 |           3 |        1 |        3 |        0 |        0 |        0 |     96 |     97 |      0 |      0 |      0 | {0.3334,0.3333,0.3333} | {0.3332}    | (null)      | (null)      | (null)      | {1,0,2}          | (null)     | (null)     | (null)     | (null)
141  public  | st1_exp |       30 |     10000 |             0 |       30 | lower   | pg_catalog          | text    |        -1 | f          |           0 |        5 |           3 |        1 |        3 |        0 |        0 |        0 |     98 |    664 |      0 |      0 |      0 | {0.3334,0.3333,0.3333} | {0.3332}    | (null)      | (null)      | (null)      | {1,0,2}          | (null)     | (null)     | (null)     | (null)
142  public  | st1_idx |       30 |     10000 |             0 |       30 |         | (null)              | (null)  |    (null) | (null)     |      (null) |   (null) |      (null) |   (null) |   (null) |   (null) |   (null) |   (null) | (null) | (null) | (null) | (null) | (null) | (null)                 | (null)      | (null)      | (null)      | (null)      | (null)           | (null)     | (null)     | (null)     | (null)
143  s0      | sft0    |        0 |         0 |             0 |        0 |         | (null)              | (null)  |    (null) | (null)     |      (null) |   (null) |      (null) |   (null) |   (null) |   (null) |   (null) |   (null) | (null) | (null) | (null) | (null) | (null) | (null)                 | (null)      | (null)      | (null)      | (null)      | (null)           | (null)     | (null)     | (null)     | (null)
144  s0      | st0     |        1 |         2 |             1 |        1 | id      | pg_catalog          | int4    |        -1 | f          |           0 |        4 |          -1 |        2 |        3 |        0 |        0 |        0 |     97 |     97 |      0 |      0 |      0 | (null)                 | {1}         | (null)      | (null)      | (null)      | {1,2}            | (null)     | (null)     | (null)     | (null)
145  s0      | st0     |        1 |         2 |             1 |        1 | id      | pg_catalog          | int4    |        -1 | t          |           0 |        4 |          -1 |        2 |        3 |        0 |        0 |        0 |     97 |     97 |      0 |      0 |      0 | (null)                 | {1}         | (null)      | (null)      | (null)      | {1,2,4,5,6}      | (null)     | (null)     | (null)     | (null)
146  s0      | st0     |        1 |         2 |             1 |        1 | num     | pg_catalog          | int4    |        -1 | f          |           0 |        4 |          -1 |        2 |        3 |        0 |        0 |        0 |     97 |     97 |      0 |      0 |      0 | (null)                 | {1}         | (null)      | (null)      | (null)      | {10,20}          | (null)     | (null)     | (null)     | (null)
147  s0      | st0     |        1 |         2 |             1 |        1 | num     | pg_catalog          | int4    |        -1 | t          |           0 |        4 |          -1 |        2 |        3 |        0 |        0 |        0 |     97 |     97 |      0 |      0 |      0 | (null)                 | {1}         | (null)      | (null)      | (null)      | {10,20,40,50,60} | (null)     | (null)     | (null)     | (null)
148  s0      | st0_idx |        2 |         2 |             0 |        2 |         | (null)              | (null)  |    (null) | (null)     |      (null) |   (null) |      (null) |   (null) |   (null) |   (null) |   (null) |   (null) | (null) | (null) | (null) | (null) | (null) | (null)                 | (null)      | (null)      | (null)      | (null)      | (null)           | (null)     | (null)     | (null)     | (null)
149  s0      | st1     |        1 |         3 |             1 |        1 | id      | pg_catalog          | int4    |        -1 | f          |           0 |        4 |          -1 |        2 |        3 |        0 |        0 |        0 |     97 |     97 |      0 |      0 |      0 | (null)                 | {1}         | (null)      | (null)      | (null)      | {4,5,6}          | (null)     | (null)     | (null)     | (null)
150  s0      | st1     |        1 |         3 |             1 |        1 | num     | pg_catalog          | int4    |        -1 | f          |           0 |        4 |          -1 |        2 |        3 |        0 |        0 |        0 |     97 |     97 |      0 |      0 |      0 | (null)                 | {1}         | (null)      | (null)      | (null)      | {40,50,60}       | (null)     | (null)     | (null)     | (null)
151  s0      | st1_idx |        2 |         3 |             0 |        2 |         | (null)              | (null)  |    (null) | (null)     |      (null) |   (null) |      (null) |   (null) |   (null) |   (null) |   (null) |   (null) | (null) | (null) | (null) | (null) | (null) | (null)                 | (null)      | (null)      | (null)      | (null)      | (null)           | (null)     | (null)     | (null)     | (null)
152  s0      | st2     |        1 |         3 |             1 |        1 | id      | pg_catalog          | int4    |        -1 | f          |           0 |        4 |          -1 |        2 |        3 |        0 |        0 |        0 |     97 |     97 |      0 |      0 |      0 | (null)                 | {1}         | (null)      | (null)      | (null)      | {1,2,3}          | (null)     | (null)     | (null)     | (null)
153  s0      | st2     |        1 |         3 |             1 |        1 | txt     | pg_catalog          | text    |        -1 | f          |           0 |        5 |          -1 |        2 |        3 |        0 |        0 |        0 |    664 |    664 |      0 |      0 |      0 | (null)                 | {0.5}       | (null)      | (null)      | (null)      | {1,comment,test} | (null)     | (null)     | (null)     | (null)
154  s0      | st2_idx |        2 |         3 |             0 |        2 |         | (null)              | (null)  |    (null) | (null)     |      (null) |   (null) |      (null) |   (null) |   (null) |   (null) |   (null) |   (null) | (null) | (null) | (null) | (null) | (null) | (null)                 | (null)      | (null)      | (null)      | (null)      | (null)           | (null)     | (null)     | (null)     | (null)
155  s0      | st3     |        0 |         0 |             0 |        0 |         | (null)              | (null)  |    (null) | (null)     |      (null) |   (null) |      (null) |   (null) |   (null) |   (null) |   (null) |   (null) | (null) | (null) | (null) | (null) | (null) | (null)                 | (null)      | (null)      | (null)      | (null)      | (null)           | (null)     | (null)     | (null)     | (null)
156  s1      | st0     |        1 |         4 |             1 |        1 | id      | pg_catalog          | int4    |        -1 | f          |           0 |        4 |          -1 |        2 |        3 |        0 |        0 |        0 |     97 |     97 |      0 |      0 |      0 | (null)                 | {1}         | (null)      | (null)      | (null)      | {1,2,3,4}        | (null)     | (null)     | (null)     | (null)
157  s1      | st0     |        1 |         4 |             1 |        1 | num     | pg_catalog          | int4    |        -1 | f          |           0 |        4 |          -1 |        2 |        3 |        0 |        0 |        0 |     97 |     97 |      0 |      0 |      0 | (null)                 | {1}         | (null)      | (null)      | (null)      | {15,25,35,45}    | (null)     | (null)     | (null)     | (null)
158 (24 rows)
159
160 TRUNCATE dbms_stats.work;
161 -- No.16-1-2
162 \! sed '/ORDER/i\\ AND n2.nspname = '"\'s0\'" export_plain_stats.sql.sample > export_plain_stats.sql.sample_test
163 \i export_plain_stats.sql.sample_test
164 /*
165  * If you want the statistics of per-relation or per-column, please modify
166  * nspname, relname, and attname in 'WHERE' clause.
167  */
168 BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE;
169 /*
170  * If you want to chage the output file name, please modify the following name.
171  */
172 \o export_stats.dmp
173 COPY (SELECT n2.nspname,
174              c.relname,
175              c.relpages,
176              c.reltuples,
177              c.relallvisible,
178              (pg_relation_size(c.oid) / current_setting('block_size')::int4)::int4
179                  AS curpages,
180              pg_catalog.pg_stat_get_last_analyze_time(c.oid)
181                  AS last_analyze,
182              pg_catalog.pg_stat_get_last_autoanalyze_time(c.oid)
183                  AS last_autoanalyze,
184              COALESCE(a.attname, ''),
185              n1.nspname AS schemaname_of_atttype,
186              t.typname,
187              a.atttypmod,
188              s.stainherit,
189              s.stanullfrac,
190              s.stawidth,
191              s.stadistinct,
192              s.stakind1,
193              s.stakind2,
194              s.stakind3,
195              s.stakind4,
196              s.stakind5,
197              s.staop1,
198              s.staop2,
199              s.staop3,
200              s.staop4,
201              s.staop5,
202              s.stanumbers1,
203              s.stanumbers2,
204              s.stanumbers3,
205              s.stanumbers4,
206              s.stanumbers5,
207              s.stavalues1,
208              s.stavalues2,
209              s.stavalues3,
210              s.stavalues4,
211              s.stavalues5
212         FROM pg_statistic s
213         JOIN pg_attribute a
214           ON (s.starelid = a.attrelid AND s.staattnum = a.attnum)
215         JOIN pg_type t
216           ON a.atttypid = t.oid
217         JOIN pg_namespace n1
218           ON t.typnamespace = n1.oid
219        RIGHT JOIN pg_catalog.pg_class c
220           ON s.starelid = c.oid
221         JOIN pg_catalog.pg_namespace n2
222           ON c.relnamespace = n2.oid
223        WHERE c.relkind IN ('r', 'i', 'f')
224          AND NOT n2.nspname IN ('pg_catalog',
225                                 'pg_toast',
226                                 'information_schema',
227                                 'dbms_stats')
228         -- AND n2.nspname = 'public'
229         -- AND c.relname = 'test'
230         -- AND a.attname = 'id'
231  AND n2.nspname = 's0'
232        ORDER BY starelid, staattnum)
233 TO STDOUT
234 (FORMAT 'binary');
235 \o
236 COMMIT;
237 COPY dbms_stats.work FROM '@abs_srcdir@/export_stats.dmp' (FORMAT 'binary');
238 SELECT * FROM work_v;
239  nspname | relname | relpages | reltuples | relallvisible | curpages | attname | nspname_of_typename | typname | atttypmod | stainherit | stanullfrac | stawidth | stadistinct | stakind1 | stakind2 | stakind3 | stakind4 | stakind5 | staop1 | staop2 | staop3 | staop4 | staop5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 |    stavalues1    | stavalues2 | stavalues3 | stavalues4 | stavalues5 
240 ---------+---------+----------+-----------+---------------+----------+---------+---------------------+---------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+-------------+-------------+-------------+-------------+-------------+------------------+------------+------------+------------+------------
241  s0      | sft0    |        0 |         0 |             0 |        0 |         | (null)              | (null)  |    (null) | (null)     |      (null) |   (null) |      (null) |   (null) |   (null) |   (null) |   (null) |   (null) | (null) | (null) | (null) | (null) | (null) | (null)      | (null)      | (null)      | (null)      | (null)      | (null)           | (null)     | (null)     | (null)     | (null)
242  s0      | st0     |        1 |         2 |             1 |        1 | id      | pg_catalog          | int4    |        -1 | f          |           0 |        4 |          -1 |        2 |        3 |        0 |        0 |        0 |     97 |     97 |      0 |      0 |      0 | (null)      | {1}         | (null)      | (null)      | (null)      | {1,2}            | (null)     | (null)     | (null)     | (null)
243  s0      | st0     |        1 |         2 |             1 |        1 | id      | pg_catalog          | int4    |        -1 | t          |           0 |        4 |          -1 |        2 |        3 |        0 |        0 |        0 |     97 |     97 |      0 |      0 |      0 | (null)      | {1}         | (null)      | (null)      | (null)      | {1,2,4,5,6}      | (null)     | (null)     | (null)     | (null)
244  s0      | st0     |        1 |         2 |             1 |        1 | num     | pg_catalog          | int4    |        -1 | f          |           0 |        4 |          -1 |        2 |        3 |        0 |        0 |        0 |     97 |     97 |      0 |      0 |      0 | (null)      | {1}         | (null)      | (null)      | (null)      | {10,20}          | (null)     | (null)     | (null)     | (null)
245  s0      | st0     |        1 |         2 |             1 |        1 | num     | pg_catalog          | int4    |        -1 | t          |           0 |        4 |          -1 |        2 |        3 |        0 |        0 |        0 |     97 |     97 |      0 |      0 |      0 | (null)      | {1}         | (null)      | (null)      | (null)      | {10,20,40,50,60} | (null)     | (null)     | (null)     | (null)
246  s0      | st0_idx |        2 |         2 |             0 |        2 |         | (null)              | (null)  |    (null) | (null)     |      (null) |   (null) |      (null) |   (null) |   (null) |   (null) |   (null) |   (null) | (null) | (null) | (null) | (null) | (null) | (null)      | (null)      | (null)      | (null)      | (null)      | (null)           | (null)     | (null)     | (null)     | (null)
247  s0      | st1     |        1 |         3 |             1 |        1 | id      | pg_catalog          | int4    |        -1 | f          |           0 |        4 |          -1 |        2 |        3 |        0 |        0 |        0 |     97 |     97 |      0 |      0 |      0 | (null)      | {1}         | (null)      | (null)      | (null)      | {4,5,6}          | (null)     | (null)     | (null)     | (null)
248  s0      | st1     |        1 |         3 |             1 |        1 | num     | pg_catalog          | int4    |        -1 | f          |           0 |        4 |          -1 |        2 |        3 |        0 |        0 |        0 |     97 |     97 |      0 |      0 |      0 | (null)      | {1}         | (null)      | (null)      | (null)      | {40,50,60}       | (null)     | (null)     | (null)     | (null)
249  s0      | st1_idx |        2 |         3 |             0 |        2 |         | (null)              | (null)  |    (null) | (null)     |      (null) |   (null) |      (null) |   (null) |   (null) |   (null) |   (null) |   (null) | (null) | (null) | (null) | (null) | (null) | (null)      | (null)      | (null)      | (null)      | (null)      | (null)           | (null)     | (null)     | (null)     | (null)
250  s0      | st2     |        1 |         3 |             1 |        1 | id      | pg_catalog          | int4    |        -1 | f          |           0 |        4 |          -1 |        2 |        3 |        0 |        0 |        0 |     97 |     97 |      0 |      0 |      0 | (null)      | {1}         | (null)      | (null)      | (null)      | {1,2,3}          | (null)     | (null)     | (null)     | (null)
251  s0      | st2     |        1 |         3 |             1 |        1 | txt     | pg_catalog          | text    |        -1 | f          |           0 |        5 |          -1 |        2 |        3 |        0 |        0 |        0 |    664 |    664 |      0 |      0 |      0 | (null)      | {0.5}       | (null)      | (null)      | (null)      | {1,comment,test} | (null)     | (null)     | (null)     | (null)
252  s0      | st2_idx |        2 |         3 |             0 |        2 |         | (null)              | (null)  |    (null) | (null)     |      (null) |   (null) |      (null) |   (null) |   (null) |   (null) |   (null) |   (null) | (null) | (null) | (null) | (null) | (null) | (null)      | (null)      | (null)      | (null)      | (null)      | (null)           | (null)     | (null)     | (null)     | (null)
253  s0      | st3     |        0 |         0 |             0 |        0 |         | (null)              | (null)  |    (null) | (null)     |      (null) |   (null) |      (null) |   (null) |   (null) |   (null) |   (null) |   (null) | (null) | (null) | (null) | (null) | (null) | (null)      | (null)      | (null)      | (null)      | (null)      | (null)           | (null)     | (null)     | (null)     | (null)
254 (13 rows)
255
256 TRUNCATE dbms_stats.work;
257 \! rm export_plain_stats.sql.sample_test
258 -- No.16-1-3
259 \! sed '/ORDER/i\\ AND c.relname = '"\'st0\'" export_plain_stats.sql.sample > export_plain_stats.sql.sample_test
260 \i export_plain_stats.sql.sample_test
261 /*
262  * If you want the statistics of per-relation or per-column, please modify
263  * nspname, relname, and attname in 'WHERE' clause.
264  */
265 BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE;
266 /*
267  * If you want to chage the output file name, please modify the following name.
268  */
269 \o export_stats.dmp
270 COPY (SELECT n2.nspname,
271              c.relname,
272              c.relpages,
273              c.reltuples,
274              c.relallvisible,
275              (pg_relation_size(c.oid) / current_setting('block_size')::int4)::int4
276                  AS curpages,
277              pg_catalog.pg_stat_get_last_analyze_time(c.oid)
278                  AS last_analyze,
279              pg_catalog.pg_stat_get_last_autoanalyze_time(c.oid)
280                  AS last_autoanalyze,
281              COALESCE(a.attname, ''),
282              n1.nspname AS schemaname_of_atttype,
283              t.typname,
284              a.atttypmod,
285              s.stainherit,
286              s.stanullfrac,
287              s.stawidth,
288              s.stadistinct,
289              s.stakind1,
290              s.stakind2,
291              s.stakind3,
292              s.stakind4,
293              s.stakind5,
294              s.staop1,
295              s.staop2,
296              s.staop3,
297              s.staop4,
298              s.staop5,
299              s.stanumbers1,
300              s.stanumbers2,
301              s.stanumbers3,
302              s.stanumbers4,
303              s.stanumbers5,
304              s.stavalues1,
305              s.stavalues2,
306              s.stavalues3,
307              s.stavalues4,
308              s.stavalues5
309         FROM pg_statistic s
310         JOIN pg_attribute a
311           ON (s.starelid = a.attrelid AND s.staattnum = a.attnum)
312         JOIN pg_type t
313           ON a.atttypid = t.oid
314         JOIN pg_namespace n1
315           ON t.typnamespace = n1.oid
316        RIGHT JOIN pg_catalog.pg_class c
317           ON s.starelid = c.oid
318         JOIN pg_catalog.pg_namespace n2
319           ON c.relnamespace = n2.oid
320        WHERE c.relkind IN ('r', 'i', 'f')
321          AND NOT n2.nspname IN ('pg_catalog',
322                                 'pg_toast',
323                                 'information_schema',
324                                 'dbms_stats')
325         -- AND n2.nspname = 'public'
326         -- AND c.relname = 'test'
327         -- AND a.attname = 'id'
328  AND c.relname = 'st0'
329        ORDER BY starelid, staattnum)
330 TO STDOUT
331 (FORMAT 'binary');
332 \o
333 COMMIT;
334 COPY dbms_stats.work FROM '@abs_srcdir@/export_stats.dmp' (FORMAT 'binary');
335 SELECT * FROM work_v;
336  nspname | relname | relpages | reltuples | relallvisible | curpages | attname | nspname_of_typename | typname | atttypmod | stainherit | stanullfrac | stawidth | stadistinct | stakind1 | stakind2 | stakind3 | stakind4 | stakind5 | staop1 | staop2 | staop3 | staop4 | staop5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 |    stavalues1    | stavalues2 | stavalues3 | stavalues4 | stavalues5 
337 ---------+---------+----------+-----------+---------------+----------+---------+---------------------+---------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+-------------+-------------+-------------+-------------+-------------+------------------+------------+------------+------------+------------
338  public  | st0     |        1 |         2 |             1 |        1 | id      | pg_catalog          | int4    |        -1 | f          |           0 |        4 |          -1 |        2 |        3 |        0 |        0 |        0 |     97 |     97 |      0 |      0 |      0 | (null)      | {1}         | (null)      | (null)      | (null)      | {1,2}            | (null)     | (null)     | (null)     | (null)
339  public  | st0     |        1 |         2 |             1 |        1 | name    | pg_catalog          | bpchar  |         9 | f          |           0 |        6 |        -0.5 |        1 |        3 |        0 |        0 |        0 |   1054 |   1058 |      0 |      0 |      0 | {1}         | {1}         | (null)      | (null)      | (null)      | {"test "}        | (null)     | (null)     | (null)     | (null)
340  s0      | st0     |        1 |         2 |             1 |        1 | id      | pg_catalog          | int4    |        -1 | f          |           0 |        4 |          -1 |        2 |        3 |        0 |        0 |        0 |     97 |     97 |      0 |      0 |      0 | (null)      | {1}         | (null)      | (null)      | (null)      | {1,2}            | (null)     | (null)     | (null)     | (null)
341  s0      | st0     |        1 |         2 |             1 |        1 | id      | pg_catalog          | int4    |        -1 | t          |           0 |        4 |          -1 |        2 |        3 |        0 |        0 |        0 |     97 |     97 |      0 |      0 |      0 | (null)      | {1}         | (null)      | (null)      | (null)      | {1,2,4,5,6}      | (null)     | (null)     | (null)     | (null)
342  s0      | st0     |        1 |         2 |             1 |        1 | num     | pg_catalog          | int4    |        -1 | f          |           0 |        4 |          -1 |        2 |        3 |        0 |        0 |        0 |     97 |     97 |      0 |      0 |      0 | (null)      | {1}         | (null)      | (null)      | (null)      | {10,20}          | (null)     | (null)     | (null)     | (null)
343  s0      | st0     |        1 |         2 |             1 |        1 | num     | pg_catalog          | int4    |        -1 | t          |           0 |        4 |          -1 |        2 |        3 |        0 |        0 |        0 |     97 |     97 |      0 |      0 |      0 | (null)      | {1}         | (null)      | (null)      | (null)      | {10,20,40,50,60} | (null)     | (null)     | (null)     | (null)
344  s1      | st0     |        1 |         4 |             1 |        1 | id      | pg_catalog          | int4    |        -1 | f          |           0 |        4 |          -1 |        2 |        3 |        0 |        0 |        0 |     97 |     97 |      0 |      0 |      0 | (null)      | {1}         | (null)      | (null)      | (null)      | {1,2,3,4}        | (null)     | (null)     | (null)     | (null)
345  s1      | st0     |        1 |         4 |             1 |        1 | num     | pg_catalog          | int4    |        -1 | f          |           0 |        4 |          -1 |        2 |        3 |        0 |        0 |        0 |     97 |     97 |      0 |      0 |      0 | (null)      | {1}         | (null)      | (null)      | (null)      | {15,25,35,45}    | (null)     | (null)     | (null)     | (null)
346 (8 rows)
347
348 TRUNCATE dbms_stats.work;
349 \! rm export_plain_stats.sql.sample_test
350 -- No.16-1-4
351 \! sed '/ORDER/i\\ AND c.relname = '"\'pg_toast_1262\'" export_plain_stats.sql.sample > export_plain_stats.sql.sample_test
352 \i export_plain_stats.sql.sample_test
353 /*
354  * If you want the statistics of per-relation or per-column, please modify
355  * nspname, relname, and attname in 'WHERE' clause.
356  */
357 BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE;
358 /*
359  * If you want to chage the output file name, please modify the following name.
360  */
361 \o export_stats.dmp
362 COPY (SELECT n2.nspname,
363              c.relname,
364              c.relpages,
365              c.reltuples,
366              c.relallvisible,
367              (pg_relation_size(c.oid) / current_setting('block_size')::int4)::int4
368                  AS curpages,
369              pg_catalog.pg_stat_get_last_analyze_time(c.oid)
370                  AS last_analyze,
371              pg_catalog.pg_stat_get_last_autoanalyze_time(c.oid)
372                  AS last_autoanalyze,
373              COALESCE(a.attname, ''),
374              n1.nspname AS schemaname_of_atttype,
375              t.typname,
376              a.atttypmod,
377              s.stainherit,
378              s.stanullfrac,
379              s.stawidth,
380              s.stadistinct,
381              s.stakind1,
382              s.stakind2,
383              s.stakind3,
384              s.stakind4,
385              s.stakind5,
386              s.staop1,
387              s.staop2,
388              s.staop3,
389              s.staop4,
390              s.staop5,
391              s.stanumbers1,
392              s.stanumbers2,
393              s.stanumbers3,
394              s.stanumbers4,
395              s.stanumbers5,
396              s.stavalues1,
397              s.stavalues2,
398              s.stavalues3,
399              s.stavalues4,
400              s.stavalues5
401         FROM pg_statistic s
402         JOIN pg_attribute a
403           ON (s.starelid = a.attrelid AND s.staattnum = a.attnum)
404         JOIN pg_type t
405           ON a.atttypid = t.oid
406         JOIN pg_namespace n1
407           ON t.typnamespace = n1.oid
408        RIGHT JOIN pg_catalog.pg_class c
409           ON s.starelid = c.oid
410         JOIN pg_catalog.pg_namespace n2
411           ON c.relnamespace = n2.oid
412        WHERE c.relkind IN ('r', 'i', 'f')
413          AND NOT n2.nspname IN ('pg_catalog',
414                                 'pg_toast',
415                                 'information_schema',
416                                 'dbms_stats')
417         -- AND n2.nspname = 'public'
418         -- AND c.relname = 'test'
419         -- AND a.attname = 'id'
420  AND c.relname = 'pg_toast_1262'
421        ORDER BY starelid, staattnum)
422 TO STDOUT
423 (FORMAT 'binary');
424 \o
425 COMMIT;
426 COPY dbms_stats.work FROM '@abs_srcdir@/export_stats.dmp' (FORMAT 'binary');
427 SELECT * FROM work_v;
428  nspname | relname | relpages | reltuples | relallvisible | curpages | attname | nspname_of_typename | typname | atttypmod | stainherit | stanullfrac | stawidth | stadistinct | stakind1 | stakind2 | stakind3 | stakind4 | stakind5 | staop1 | staop2 | staop3 | staop4 | staop5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1 | stavalues2 | stavalues3 | stavalues4 | stavalues5 
429 ---------+---------+----------+-----------+---------------+----------+---------+---------------------+---------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+-------------+-------------+-------------+-------------+-------------+------------+------------+------------+------------+------------
430 (0 rows)
431
432 TRUNCATE dbms_stats.work;
433 \! rm export_plain_stats.sql.sample_test
434 -- No.16-1-5
435 \! sed '/ORDER/i\\ AND c.relname = '"\'st0_idx\'" export_plain_stats.sql.sample > export_plain_stats.sql.sample_test
436 \i export_plain_stats.sql.sample_test
437 /*
438  * If you want the statistics of per-relation or per-column, please modify
439  * nspname, relname, and attname in 'WHERE' clause.
440  */
441 BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE;
442 /*
443  * If you want to chage the output file name, please modify the following name.
444  */
445 \o export_stats.dmp
446 COPY (SELECT n2.nspname,
447              c.relname,
448              c.relpages,
449              c.reltuples,
450              c.relallvisible,
451              (pg_relation_size(c.oid) / current_setting('block_size')::int4)::int4
452                  AS curpages,
453              pg_catalog.pg_stat_get_last_analyze_time(c.oid)
454                  AS last_analyze,
455              pg_catalog.pg_stat_get_last_autoanalyze_time(c.oid)
456                  AS last_autoanalyze,
457              COALESCE(a.attname, ''),
458              n1.nspname AS schemaname_of_atttype,
459              t.typname,
460              a.atttypmod,
461              s.stainherit,
462              s.stanullfrac,
463              s.stawidth,
464              s.stadistinct,
465              s.stakind1,
466              s.stakind2,
467              s.stakind3,
468              s.stakind4,
469              s.stakind5,
470              s.staop1,
471              s.staop2,
472              s.staop3,
473              s.staop4,
474              s.staop5,
475              s.stanumbers1,
476              s.stanumbers2,
477              s.stanumbers3,
478              s.stanumbers4,
479              s.stanumbers5,
480              s.stavalues1,
481              s.stavalues2,
482              s.stavalues3,
483              s.stavalues4,
484              s.stavalues5
485         FROM pg_statistic s
486         JOIN pg_attribute a
487           ON (s.starelid = a.attrelid AND s.staattnum = a.attnum)
488         JOIN pg_type t
489           ON a.atttypid = t.oid
490         JOIN pg_namespace n1
491           ON t.typnamespace = n1.oid
492        RIGHT JOIN pg_catalog.pg_class c
493           ON s.starelid = c.oid
494         JOIN pg_catalog.pg_namespace n2
495           ON c.relnamespace = n2.oid
496        WHERE c.relkind IN ('r', 'i', 'f')
497          AND NOT n2.nspname IN ('pg_catalog',
498                                 'pg_toast',
499                                 'information_schema',
500                                 'dbms_stats')
501         -- AND n2.nspname = 'public'
502         -- AND c.relname = 'test'
503         -- AND a.attname = 'id'
504  AND c.relname = 'st0_idx'
505        ORDER BY starelid, staattnum)
506 TO STDOUT
507 (FORMAT 'binary');
508 \o
509 COMMIT;
510 COPY dbms_stats.work FROM '@abs_srcdir@/export_stats.dmp' (FORMAT 'binary');
511 SELECT * FROM work_v;
512  nspname | relname | relpages | reltuples | relallvisible | curpages | attname | nspname_of_typename | typname | atttypmod | stainherit | stanullfrac | stawidth | stadistinct | stakind1 | stakind2 | stakind3 | stakind4 | stakind5 | staop1 | staop2 | staop3 | staop4 | staop5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1 | stavalues2 | stavalues3 | stavalues4 | stavalues5 
513 ---------+---------+----------+-----------+---------------+----------+---------+---------------------+---------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+-------------+-------------+-------------+-------------+-------------+------------+------------+------------+------------+------------
514  public  | st0_idx |        2 |         2 |             0 |        2 |         | (null)              | (null)  |    (null) | (null)     |      (null) |   (null) |      (null) |   (null) |   (null) |   (null) |   (null) |   (null) | (null) | (null) | (null) | (null) | (null) | (null)      | (null)      | (null)      | (null)      | (null)      | (null)     | (null)     | (null)     | (null)     | (null)
515  s0      | st0_idx |        2 |         2 |             0 |        2 |         | (null)              | (null)  |    (null) | (null)     |      (null) |   (null) |      (null) |   (null) |   (null) |   (null) |   (null) |   (null) | (null) | (null) | (null) | (null) | (null) | (null)      | (null)      | (null)      | (null)      | (null)      | (null)     | (null)     | (null)     | (null)     | (null)
516 (2 rows)
517
518 TRUNCATE dbms_stats.work;
519 \! rm export_plain_stats.sql.sample_test
520 -- No.16-1-6
521 \! sed '/ORDER/i\\ AND c.relname = '"\'ss0\'" export_plain_stats.sql.sample > export_plain_stats.sql.sample_test
522 \i export_plain_stats.sql.sample_test
523 /*
524  * If you want the statistics of per-relation or per-column, please modify
525  * nspname, relname, and attname in 'WHERE' clause.
526  */
527 BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE;
528 /*
529  * If you want to chage the output file name, please modify the following name.
530  */
531 \o export_stats.dmp
532 COPY (SELECT n2.nspname,
533              c.relname,
534              c.relpages,
535              c.reltuples,
536              c.relallvisible,
537              (pg_relation_size(c.oid) / current_setting('block_size')::int4)::int4
538                  AS curpages,
539              pg_catalog.pg_stat_get_last_analyze_time(c.oid)
540                  AS last_analyze,
541              pg_catalog.pg_stat_get_last_autoanalyze_time(c.oid)
542                  AS last_autoanalyze,
543              COALESCE(a.attname, ''),
544              n1.nspname AS schemaname_of_atttype,
545              t.typname,
546              a.atttypmod,
547              s.stainherit,
548              s.stanullfrac,
549              s.stawidth,
550              s.stadistinct,
551              s.stakind1,
552              s.stakind2,
553              s.stakind3,
554              s.stakind4,
555              s.stakind5,
556              s.staop1,
557              s.staop2,
558              s.staop3,
559              s.staop4,
560              s.staop5,
561              s.stanumbers1,
562              s.stanumbers2,
563              s.stanumbers3,
564              s.stanumbers4,
565              s.stanumbers5,
566              s.stavalues1,
567              s.stavalues2,
568              s.stavalues3,
569              s.stavalues4,
570              s.stavalues5
571         FROM pg_statistic s
572         JOIN pg_attribute a
573           ON (s.starelid = a.attrelid AND s.staattnum = a.attnum)
574         JOIN pg_type t
575           ON a.atttypid = t.oid
576         JOIN pg_namespace n1
577           ON t.typnamespace = n1.oid
578        RIGHT JOIN pg_catalog.pg_class c
579           ON s.starelid = c.oid
580         JOIN pg_catalog.pg_namespace n2
581           ON c.relnamespace = n2.oid
582        WHERE c.relkind IN ('r', 'i', 'f')
583          AND NOT n2.nspname IN ('pg_catalog',
584                                 'pg_toast',
585                                 'information_schema',
586                                 'dbms_stats')
587         -- AND n2.nspname = 'public'
588         -- AND c.relname = 'test'
589         -- AND a.attname = 'id'
590  AND c.relname = 'ss0'
591        ORDER BY starelid, staattnum)
592 TO STDOUT
593 (FORMAT 'binary');
594 \o
595 COMMIT;
596 COPY dbms_stats.work FROM '@abs_srcdir@/export_stats.dmp' (FORMAT 'binary');
597 SELECT * FROM work_v;
598  nspname | relname | relpages | reltuples | relallvisible | curpages | attname | nspname_of_typename | typname | atttypmod | stainherit | stanullfrac | stawidth | stadistinct | stakind1 | stakind2 | stakind3 | stakind4 | stakind5 | staop1 | staop2 | staop3 | staop4 | staop5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1 | stavalues2 | stavalues3 | stavalues4 | stavalues5 
599 ---------+---------+----------+-----------+---------------+----------+---------+---------------------+---------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+-------------+-------------+-------------+-------------+-------------+------------+------------+------------+------------+------------
600 (0 rows)
601
602 TRUNCATE dbms_stats.work;
603 \! rm export_plain_stats.sql.sample_test
604 -- No.16-1-7
605 \! sed '/ORDER/i\\ AND c.relname = '"\'sc0\'" export_plain_stats.sql.sample > export_plain_stats.sql.sample_test
606 \i export_plain_stats.sql.sample_test
607 /*
608  * If you want the statistics of per-relation or per-column, please modify
609  * nspname, relname, and attname in 'WHERE' clause.
610  */
611 BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE;
612 /*
613  * If you want to chage the output file name, please modify the following name.
614  */
615 \o export_stats.dmp
616 COPY (SELECT n2.nspname,
617              c.relname,
618              c.relpages,
619              c.reltuples,
620              c.relallvisible,
621              (pg_relation_size(c.oid) / current_setting('block_size')::int4)::int4
622                  AS curpages,
623              pg_catalog.pg_stat_get_last_analyze_time(c.oid)
624                  AS last_analyze,
625              pg_catalog.pg_stat_get_last_autoanalyze_time(c.oid)
626                  AS last_autoanalyze,
627              COALESCE(a.attname, ''),
628              n1.nspname AS schemaname_of_atttype,
629              t.typname,
630              a.atttypmod,
631              s.stainherit,
632              s.stanullfrac,
633              s.stawidth,
634              s.stadistinct,
635              s.stakind1,
636              s.stakind2,
637              s.stakind3,
638              s.stakind4,
639              s.stakind5,
640              s.staop1,
641              s.staop2,
642              s.staop3,
643              s.staop4,
644              s.staop5,
645              s.stanumbers1,
646              s.stanumbers2,
647              s.stanumbers3,
648              s.stanumbers4,
649              s.stanumbers5,
650              s.stavalues1,
651              s.stavalues2,
652              s.stavalues3,
653              s.stavalues4,
654              s.stavalues5
655         FROM pg_statistic s
656         JOIN pg_attribute a
657           ON (s.starelid = a.attrelid AND s.staattnum = a.attnum)
658         JOIN pg_type t
659           ON a.atttypid = t.oid
660         JOIN pg_namespace n1
661           ON t.typnamespace = n1.oid
662        RIGHT JOIN pg_catalog.pg_class c
663           ON s.starelid = c.oid
664         JOIN pg_catalog.pg_namespace n2
665           ON c.relnamespace = n2.oid
666        WHERE c.relkind IN ('r', 'i', 'f')
667          AND NOT n2.nspname IN ('pg_catalog',
668                                 'pg_toast',
669                                 'information_schema',
670                                 'dbms_stats')
671         -- AND n2.nspname = 'public'
672         -- AND c.relname = 'test'
673         -- AND a.attname = 'id'
674  AND c.relname = 'sc0'
675        ORDER BY starelid, staattnum)
676 TO STDOUT
677 (FORMAT 'binary');
678 \o
679 COMMIT;
680 COPY dbms_stats.work FROM '@abs_srcdir@/export_stats.dmp' (FORMAT 'binary');
681 SELECT * FROM work_v;
682  nspname | relname | relpages | reltuples | relallvisible | curpages | attname | nspname_of_typename | typname | atttypmod | stainherit | stanullfrac | stawidth | stadistinct | stakind1 | stakind2 | stakind3 | stakind4 | stakind5 | staop1 | staop2 | staop3 | staop4 | staop5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1 | stavalues2 | stavalues3 | stavalues4 | stavalues5 
683 ---------+---------+----------+-----------+---------------+----------+---------+---------------------+---------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+-------------+-------------+-------------+-------------+-------------+------------+------------+------------+------------+------------
684 (0 rows)
685
686 TRUNCATE dbms_stats.work;
687 \! rm export_plain_stats.sql.sample_test
688 -- No.16-1-8
689 \! sed '/ORDER/i\\ AND c.relname = '"\'sft0\'" export_plain_stats.sql.sample > export_plain_stats.sql.sample_test
690 \i export_plain_stats.sql.sample_test
691 /*
692  * If you want the statistics of per-relation or per-column, please modify
693  * nspname, relname, and attname in 'WHERE' clause.
694  */
695 BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE;
696 /*
697  * If you want to chage the output file name, please modify the following name.
698  */
699 \o export_stats.dmp
700 COPY (SELECT n2.nspname,
701              c.relname,
702              c.relpages,
703              c.reltuples,
704              c.relallvisible,
705              (pg_relation_size(c.oid) / current_setting('block_size')::int4)::int4
706                  AS curpages,
707              pg_catalog.pg_stat_get_last_analyze_time(c.oid)
708                  AS last_analyze,
709              pg_catalog.pg_stat_get_last_autoanalyze_time(c.oid)
710                  AS last_autoanalyze,
711              COALESCE(a.attname, ''),
712              n1.nspname AS schemaname_of_atttype,
713              t.typname,
714              a.atttypmod,
715              s.stainherit,
716              s.stanullfrac,
717              s.stawidth,
718              s.stadistinct,
719              s.stakind1,
720              s.stakind2,
721              s.stakind3,
722              s.stakind4,
723              s.stakind5,
724              s.staop1,
725              s.staop2,
726              s.staop3,
727              s.staop4,
728              s.staop5,
729              s.stanumbers1,
730              s.stanumbers2,
731              s.stanumbers3,
732              s.stanumbers4,
733              s.stanumbers5,
734              s.stavalues1,
735              s.stavalues2,
736              s.stavalues3,
737              s.stavalues4,
738              s.stavalues5
739         FROM pg_statistic s
740         JOIN pg_attribute a
741           ON (s.starelid = a.attrelid AND s.staattnum = a.attnum)
742         JOIN pg_type t
743           ON a.atttypid = t.oid
744         JOIN pg_namespace n1
745           ON t.typnamespace = n1.oid
746        RIGHT JOIN pg_catalog.pg_class c
747           ON s.starelid = c.oid
748         JOIN pg_catalog.pg_namespace n2
749           ON c.relnamespace = n2.oid
750        WHERE c.relkind IN ('r', 'i', 'f')
751          AND NOT n2.nspname IN ('pg_catalog',
752                                 'pg_toast',
753                                 'information_schema',
754                                 'dbms_stats')
755         -- AND n2.nspname = 'public'
756         -- AND c.relname = 'test'
757         -- AND a.attname = 'id'
758  AND c.relname = 'sft0'
759        ORDER BY starelid, staattnum)
760 TO STDOUT
761 (FORMAT 'binary');
762 \o
763 COMMIT;
764 COPY dbms_stats.work FROM '@abs_srcdir@/export_stats.dmp' (FORMAT 'binary');
765 SELECT * FROM work_v;
766  nspname | relname | relpages | reltuples | relallvisible | curpages | attname | nspname_of_typename | typname | atttypmod | stainherit | stanullfrac | stawidth | stadistinct | stakind1 | stakind2 | stakind3 | stakind4 | stakind5 | staop1 | staop2 | staop3 | staop4 | staop5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1 | stavalues2 | stavalues3 | stavalues4 | stavalues5 
767 ---------+---------+----------+-----------+---------------+----------+---------+---------------------+---------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+-------------+-------------+-------------+-------------+-------------+------------+------------+------------+------------+------------
768  s0      | sft0    |        0 |         0 |             0 |        0 |         | (null)              | (null)  |    (null) | (null)     |      (null) |   (null) |      (null) |   (null) |   (null) |   (null) |   (null) |   (null) | (null) | (null) | (null) | (null) | (null) | (null)      | (null)      | (null)      | (null)      | (null)      | (null)     | (null)     | (null)     | (null)     | (null)
769 (1 row)
770
771 TRUNCATE dbms_stats.work;
772 \! rm export_plain_stats.sql.sample_test
773 -- No.16-1-9
774 \! sed '/ORDER/i\\ AND n2.nspname = '"\'s0\'"' AND a.attname = '\'id\' export_plain_stats.sql.sample > export_plain_stats.sql.sample_test
775 \i export_plain_stats.sql.sample_test
776 /*
777  * If you want the statistics of per-relation or per-column, please modify
778  * nspname, relname, and attname in 'WHERE' clause.
779  */
780 BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE;
781 /*
782  * If you want to chage the output file name, please modify the following name.
783  */
784 \o export_stats.dmp
785 COPY (SELECT n2.nspname,
786              c.relname,
787              c.relpages,
788              c.reltuples,
789              c.relallvisible,
790              (pg_relation_size(c.oid) / current_setting('block_size')::int4)::int4
791                  AS curpages,
792              pg_catalog.pg_stat_get_last_analyze_time(c.oid)
793                  AS last_analyze,
794              pg_catalog.pg_stat_get_last_autoanalyze_time(c.oid)
795                  AS last_autoanalyze,
796              COALESCE(a.attname, ''),
797              n1.nspname AS schemaname_of_atttype,
798              t.typname,
799              a.atttypmod,
800              s.stainherit,
801              s.stanullfrac,
802              s.stawidth,
803              s.stadistinct,
804              s.stakind1,
805              s.stakind2,
806              s.stakind3,
807              s.stakind4,
808              s.stakind5,
809              s.staop1,
810              s.staop2,
811              s.staop3,
812              s.staop4,
813              s.staop5,
814              s.stanumbers1,
815              s.stanumbers2,
816              s.stanumbers3,
817              s.stanumbers4,
818              s.stanumbers5,
819              s.stavalues1,
820              s.stavalues2,
821              s.stavalues3,
822              s.stavalues4,
823              s.stavalues5
824         FROM pg_statistic s
825         JOIN pg_attribute a
826           ON (s.starelid = a.attrelid AND s.staattnum = a.attnum)
827         JOIN pg_type t
828           ON a.atttypid = t.oid
829         JOIN pg_namespace n1
830           ON t.typnamespace = n1.oid
831        RIGHT JOIN pg_catalog.pg_class c
832           ON s.starelid = c.oid
833         JOIN pg_catalog.pg_namespace n2
834           ON c.relnamespace = n2.oid
835        WHERE c.relkind IN ('r', 'i', 'f')
836          AND NOT n2.nspname IN ('pg_catalog',
837                                 'pg_toast',
838                                 'information_schema',
839                                 'dbms_stats')
840         -- AND n2.nspname = 'public'
841         -- AND c.relname = 'test'
842         -- AND a.attname = 'id'
843  AND n2.nspname = 's0' AND a.attname = 'id'
844        ORDER BY starelid, staattnum)
845 TO STDOUT
846 (FORMAT 'binary');
847 \o
848 COMMIT;
849 COPY dbms_stats.work FROM '@abs_srcdir@/export_stats.dmp' (FORMAT 'binary');
850 SELECT * FROM work_v;
851  nspname | relname | relpages | reltuples | relallvisible | curpages | attname | nspname_of_typename | typname | atttypmod | stainherit | stanullfrac | stawidth | stadistinct | stakind1 | stakind2 | stakind3 | stakind4 | stakind5 | staop1 | staop2 | staop3 | staop4 | staop5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1  | stavalues2 | stavalues3 | stavalues4 | stavalues5 
852 ---------+---------+----------+-----------+---------------+----------+---------+---------------------+---------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+-------------+-------------+-------------+-------------+-------------+-------------+------------+------------+------------+------------
853  s0      | st0     |        1 |         2 |             1 |        1 | id      | pg_catalog          | int4    |        -1 | f          |           0 |        4 |          -1 |        2 |        3 |        0 |        0 |        0 |     97 |     97 |      0 |      0 |      0 | (null)      | {1}         | (null)      | (null)      | (null)      | {1,2}       | (null)     | (null)     | (null)     | (null)
854  s0      | st0     |        1 |         2 |             1 |        1 | id      | pg_catalog          | int4    |        -1 | t          |           0 |        4 |          -1 |        2 |        3 |        0 |        0 |        0 |     97 |     97 |      0 |      0 |      0 | (null)      | {1}         | (null)      | (null)      | (null)      | {1,2,4,5,6} | (null)     | (null)     | (null)     | (null)
855  s0      | st1     |        1 |         3 |             1 |        1 | id      | pg_catalog          | int4    |        -1 | f          |           0 |        4 |          -1 |        2 |        3 |        0 |        0 |        0 |     97 |     97 |      0 |      0 |      0 | (null)      | {1}         | (null)      | (null)      | (null)      | {4,5,6}     | (null)     | (null)     | (null)     | (null)
856  s0      | st2     |        1 |         3 |             1 |        1 | id      | pg_catalog          | int4    |        -1 | f          |           0 |        4 |          -1 |        2 |        3 |        0 |        0 |        0 |     97 |     97 |      0 |      0 |      0 | (null)      | {1}         | (null)      | (null)      | (null)      | {1,2,3}     | (null)     | (null)     | (null)     | (null)
857 (4 rows)
858
859 TRUNCATE dbms_stats.work;
860 \! rm export_plain_stats.sql.sample_test
861 -- No.16-1-10
862 \! sed '/ORDER/i\\ AND n2.nspname = '"\'s0\'"' AND a.attname IS NULL' export_plain_stats.sql.sample > export_plain_stats.sql.sample_test
863 \i export_plain_stats.sql.sample_test
864 /*
865  * If you want the statistics of per-relation or per-column, please modify
866  * nspname, relname, and attname in 'WHERE' clause.
867  */
868 BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE;
869 /*
870  * If you want to chage the output file name, please modify the following name.
871  */
872 \o export_stats.dmp
873 COPY (SELECT n2.nspname,
874              c.relname,
875              c.relpages,
876              c.reltuples,
877              c.relallvisible,
878              (pg_relation_size(c.oid) / current_setting('block_size')::int4)::int4
879                  AS curpages,
880              pg_catalog.pg_stat_get_last_analyze_time(c.oid)
881                  AS last_analyze,
882              pg_catalog.pg_stat_get_last_autoanalyze_time(c.oid)
883                  AS last_autoanalyze,
884              COALESCE(a.attname, ''),
885              n1.nspname AS schemaname_of_atttype,
886              t.typname,
887              a.atttypmod,
888              s.stainherit,
889              s.stanullfrac,
890              s.stawidth,
891              s.stadistinct,
892              s.stakind1,
893              s.stakind2,
894              s.stakind3,
895              s.stakind4,
896              s.stakind5,
897              s.staop1,
898              s.staop2,
899              s.staop3,
900              s.staop4,
901              s.staop5,
902              s.stanumbers1,
903              s.stanumbers2,
904              s.stanumbers3,
905              s.stanumbers4,
906              s.stanumbers5,
907              s.stavalues1,
908              s.stavalues2,
909              s.stavalues3,
910              s.stavalues4,
911              s.stavalues5
912         FROM pg_statistic s
913         JOIN pg_attribute a
914           ON (s.starelid = a.attrelid AND s.staattnum = a.attnum)
915         JOIN pg_type t
916           ON a.atttypid = t.oid
917         JOIN pg_namespace n1
918           ON t.typnamespace = n1.oid
919        RIGHT JOIN pg_catalog.pg_class c
920           ON s.starelid = c.oid
921         JOIN pg_catalog.pg_namespace n2
922           ON c.relnamespace = n2.oid
923        WHERE c.relkind IN ('r', 'i', 'f')
924          AND NOT n2.nspname IN ('pg_catalog',
925                                 'pg_toast',
926                                 'information_schema',
927                                 'dbms_stats')
928         -- AND n2.nspname = 'public'
929         -- AND c.relname = 'test'
930         -- AND a.attname = 'id'
931  AND n2.nspname = 's0' AND a.attname IS NULL
932        ORDER BY starelid, staattnum)
933 TO STDOUT
934 (FORMAT 'binary');
935 \o
936 COMMIT;
937 COPY dbms_stats.work FROM '@abs_srcdir@/export_stats.dmp' (FORMAT 'binary');
938 SELECT * FROM work_v;
939  nspname | relname | relpages | reltuples | relallvisible | curpages | attname | nspname_of_typename | typname | atttypmod | stainherit | stanullfrac | stawidth | stadistinct | stakind1 | stakind2 | stakind3 | stakind4 | stakind5 | staop1 | staop2 | staop3 | staop4 | staop5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1 | stavalues2 | stavalues3 | stavalues4 | stavalues5 
940 ---------+---------+----------+-----------+---------------+----------+---------+---------------------+---------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+-------------+-------------+-------------+-------------+-------------+------------+------------+------------+------------+------------
941  s0      | sft0    |        0 |         0 |             0 |        0 |         | (null)              | (null)  |    (null) | (null)     |      (null) |   (null) |      (null) |   (null) |   (null) |   (null) |   (null) |   (null) | (null) | (null) | (null) | (null) | (null) | (null)      | (null)      | (null)      | (null)      | (null)      | (null)     | (null)     | (null)     | (null)     | (null)
942  s0      | st0_idx |        2 |         2 |             0 |        2 |         | (null)              | (null)  |    (null) | (null)     |      (null) |   (null) |      (null) |   (null) |   (null) |   (null) |   (null) |   (null) | (null) | (null) | (null) | (null) | (null) | (null)      | (null)      | (null)      | (null)      | (null)      | (null)     | (null)     | (null)     | (null)     | (null)
943  s0      | st1_idx |        2 |         3 |             0 |        2 |         | (null)              | (null)  |    (null) | (null)     |      (null) |   (null) |      (null) |   (null) |   (null) |   (null) |   (null) |   (null) | (null) | (null) | (null) | (null) | (null) | (null)      | (null)      | (null)      | (null)      | (null)      | (null)     | (null)     | (null)     | (null)     | (null)
944  s0      | st2_idx |        2 |         3 |             0 |        2 |         | (null)              | (null)  |    (null) | (null)     |      (null) |   (null) |      (null) |   (null) |   (null) |   (null) |   (null) |   (null) | (null) | (null) | (null) | (null) | (null) | (null)      | (null)      | (null)      | (null)      | (null)      | (null)     | (null)     | (null)     | (null)     | (null)
945  s0      | st3     |        0 |         0 |             0 |        0 |         | (null)              | (null)  |    (null) | (null)     |      (null) |   (null) |      (null) |   (null) |   (null) |   (null) |   (null) |   (null) | (null) | (null) | (null) | (null) | (null) | (null)      | (null)      | (null)      | (null)      | (null)      | (null)     | (null)     | (null)     | (null)     | (null)
946 (5 rows)
947
948 TRUNCATE dbms_stats.work;
949 \! rm export_plain_stats.sql.sample_test
950 -- No.16-1-11
951 \! sed '/ORDER/i\\ AND n2.nspname = '"\'s1\'"' AND c.relname IS NULL' export_plain_stats.sql.sample > export_plain_stats.sql.sample_test
952 \i export_plain_stats.sql.sample_test
953 /*
954  * If you want the statistics of per-relation or per-column, please modify
955  * nspname, relname, and attname in 'WHERE' clause.
956  */
957 BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE;
958 /*
959  * If you want to chage the output file name, please modify the following name.
960  */
961 \o export_stats.dmp
962 COPY (SELECT n2.nspname,
963              c.relname,
964              c.relpages,
965              c.reltuples,
966              c.relallvisible,
967              (pg_relation_size(c.oid) / current_setting('block_size')::int4)::int4
968                  AS curpages,
969              pg_catalog.pg_stat_get_last_analyze_time(c.oid)
970                  AS last_analyze,
971              pg_catalog.pg_stat_get_last_autoanalyze_time(c.oid)
972                  AS last_autoanalyze,
973              COALESCE(a.attname, ''),
974              n1.nspname AS schemaname_of_atttype,
975              t.typname,
976              a.atttypmod,
977              s.stainherit,
978              s.stanullfrac,
979              s.stawidth,
980              s.stadistinct,
981              s.stakind1,
982              s.stakind2,
983              s.stakind3,
984              s.stakind4,
985              s.stakind5,
986              s.staop1,
987              s.staop2,
988              s.staop3,
989              s.staop4,
990              s.staop5,
991              s.stanumbers1,
992              s.stanumbers2,
993              s.stanumbers3,
994              s.stanumbers4,
995              s.stanumbers5,
996              s.stavalues1,
997              s.stavalues2,
998              s.stavalues3,
999              s.stavalues4,
1000              s.stavalues5
1001         FROM pg_statistic s
1002         JOIN pg_attribute a
1003           ON (s.starelid = a.attrelid AND s.staattnum = a.attnum)
1004         JOIN pg_type t
1005           ON a.atttypid = t.oid
1006         JOIN pg_namespace n1
1007           ON t.typnamespace = n1.oid
1008        RIGHT JOIN pg_catalog.pg_class c
1009           ON s.starelid = c.oid
1010         JOIN pg_catalog.pg_namespace n2
1011           ON c.relnamespace = n2.oid
1012        WHERE c.relkind IN ('r', 'i', 'f')
1013          AND NOT n2.nspname IN ('pg_catalog',
1014                                 'pg_toast',
1015                                 'information_schema',
1016                                 'dbms_stats')
1017         -- AND n2.nspname = 'public'
1018         -- AND c.relname = 'test'
1019         -- AND a.attname = 'id'
1020  AND n2.nspname = 's1' AND c.relname IS NULL
1021        ORDER BY starelid, staattnum)
1022 TO STDOUT
1023 (FORMAT 'binary');
1024 \o
1025 COMMIT;
1026 COPY dbms_stats.work FROM '@abs_srcdir@/export_stats.dmp' (FORMAT 'binary');
1027 SELECT * FROM work_v;
1028  nspname | relname | relpages | reltuples | relallvisible | curpages | attname | nspname_of_typename | typname | atttypmod | stainherit | stanullfrac | stawidth | stadistinct | stakind1 | stakind2 | stakind3 | stakind4 | stakind5 | staop1 | staop2 | staop3 | staop4 | staop5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1 | stavalues2 | stavalues3 | stavalues4 | stavalues5 
1029 ---------+---------+----------+-----------+---------------+----------+---------+---------------------+---------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+-------------+-------------+-------------+-------------+-------------+------------+------------+------------+------------+------------
1030 (0 rows)
1031
1032 TRUNCATE dbms_stats.work;
1033 \! rm export_plain_stats.sql.sample_test
1034 /*
1035  * No.16-2 export_effective_stats.sql.sample
1036  */
1037 -- No.16-2-1
1038 VACUUM ANALYZE;
1039 SELECT dbms_stats.lock_database_stats();
1040  lock_database_stats 
1041 ---------------------
1042  pt0
1043  pt0_idx
1044  st0
1045  st0_idx
1046  st1
1047  s0.st0
1048  s0.st0_idx
1049  s0.st1
1050  s0.st1_idx
1051  s0.st2
1052  s0.st2_idx
1053  s0.sft0
1054  st1_idx
1055  st1_exp
1056  s1.st0
1057  s0.st3
1058 (16 rows)
1059
1060 UPDATE dbms_stats._relation_stats_locked
1061    SET (relpages, reltuples, relallvisible, curpages) = (NULL, NULL, NULL, NULL);
1062 UPDATE dbms_stats._column_stats_locked
1063    SET (stanullfrac, stawidth, stadistinct,
1064         stakind1, stakind2, stakind3, stakind4, stakind5,
1065         staop1, staop2, staop3, staop4, staop5,
1066         stanumbers1, stanumbers2, stanumbers3, stanumbers4, stanumbers5,
1067         stavalues1, stavalues2, stavalues3, stavalues4, stavalues5)
1068      = (NULL, NULL, NULL,
1069         NULL, NULL, NULL, NULL, NULL,
1070         NULL, NULL, NULL, NULL, NULL,
1071         NULL, NULL, NULL, NULL, NULL,
1072         NULL, NULL, NULL, NULL, NULL)
1073  WHERE starelid = 's0.st0'::regclass;
1074 \i export_effective_stats.sql.sample
1075 /*
1076  * If you want the statistics of per-relation or per-column, please modify
1077  * nspname, relname, and attname in 'WHERE' clause.
1078  */
1079 BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE;
1080 /*
1081  * If you want to chage the output file name, please modify the following name.
1082  */
1083 \o export_stats.dmp
1084 COPY (SELECT n2.nspname,
1085              cl.relname,
1086              r.relpages,
1087              r.reltuples,
1088              r.relallvisible,
1089              r.curpages,
1090              r.last_analyze,
1091              r.last_autoanalyze,
1092              COALESCE(a.attname, ''),
1093              n1.nspname AS schemaname_of_atttype,
1094              t.typname,
1095              a.atttypmod,
1096              co.stainherit,
1097              co.stanullfrac,
1098              co.stawidth,
1099              co.stadistinct,
1100              co.stakind1,
1101              co.stakind2,
1102              co.stakind3,
1103              co.stakind4,
1104              co.stakind5,
1105              co.staop1,
1106              co.staop2,
1107              co.staop3,
1108              co.staop4,
1109              co.staop5,
1110              co.stanumbers1,
1111              co.stanumbers2,
1112              co.stanumbers3,
1113              co.stanumbers4,
1114              co.stanumbers5,
1115              co.stavalues1,
1116              co.stavalues2,
1117              co.stavalues3,
1118              co.stavalues4,
1119              co.stavalues5
1120         FROM dbms_stats.column_stats_effective co
1121         JOIN pg_attribute a
1122           ON (co.starelid = a.attrelid AND co.staattnum = a.attnum)
1123         JOIN pg_type t
1124           ON a.atttypid = t.oid
1125         JOIN pg_namespace n1
1126           ON t.typnamespace = n1.oid
1127        RIGHT JOIN dbms_stats.relation_stats_effective r
1128           ON co.starelid = r.relid
1129         JOIN pg_catalog.pg_class cl
1130           ON r.relid = cl.oid
1131         JOIN pg_catalog.pg_namespace n2
1132           ON cl.relnamespace = n2.oid
1133        -- WHERE n2.nspname = 'public'
1134        -- AND cl.relname = 'test'
1135        -- AND a.attname = 'id'
1136        ORDER BY starelid, staattnum)
1137 TO STDOUT
1138 (FORMAT 'binary');
1139 \o
1140 COMMIT;
1141 COPY dbms_stats.work FROM '@abs_srcdir@/export_stats.dmp' (FORMAT 'binary');
1142 SELECT * FROM work_v;
1143  nspname | relname | relpages | reltuples | relallvisible | curpages | attname | nspname_of_typename | typname | atttypmod | stainherit | stanullfrac | stawidth | stadistinct | stakind1 | stakind2 | stakind3 | stakind4 | stakind5 | staop1 | staop2 | staop3 | staop4 | staop5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 |    stavalues1    | stavalues2 |    stavalues3    | stavalues4 | stavalues5 
1144 ---------+---------+----------+-----------+---------------+----------+---------+---------------------+---------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+-------------+-------------+-------------+-------------+-------------+------------------+------------+------------------+------------+------------
1145  public  | pt0     |        0 |         0 |             0 |        0 |         | (null)              | (null)  |    (null) | (null)     |      (null) |   (null) |      (null) |   (null) |   (null) |   (null) |   (null) |   (null) | (null) | (null) | (null) | (null) | (null) | (null)      | (null)      | (null)      | (null)      | (null)      | (null)           | (null)     | (null)           | (null)     | (null)
1146  public  | pt0_idx |        2 |         0 |             0 |        2 |         | (null)              | (null)  |    (null) | (null)     |      (null) |   (null) |      (null) |   (null) |   (null) |   (null) |   (null) |   (null) | (null) | (null) | (null) | (null) | (null) | (null)      | (null)      | (null)      | (null)      | (null)      | (null)           | (null)     | (null)           | (null)     | (null)
1147  public  | st0     |        1 |         2 |             1 |        1 | id      | pg_catalog          | int4    |        -1 | f          |          -1 |       -1 |          -1 |        2 |        3 |        4 |        1 |        5 |     22 |     23 |     24 |     21 |     25 | {-1,22}     | {-1,23}     | {-1,24}     | {-1,21}     | {-1,25}     | (null)           | (null)     | {1,2}            | (null)     | (null)
1148  public  | st0     |        1 |         2 |             1 |        1 | name    | pg_catalog          | bpchar  |         9 | f          |          -2 |       -2 |          -2 |        2 |        3 |        4 |        1 |        5 |     22 |     23 |     24 |     21 |     25 | {-2,22}     | {-2,23}     | {-2,24}     | {-2,21}     | {-2,25}     | (null)           | (null)     | {"test "}        | (null)     | (null)
1149  public  | st0_idx |        2 |         2 |             0 |        2 |         | (null)              | (null)  |    (null) | (null)     |      (null) |   (null) |      (null) |   (null) |   (null) |   (null) |   (null) |   (null) | (null) | (null) | (null) | (null) | (null) | (null)      | (null)      | (null)      | (null)      | (null)      | (null)           | (null)     | (null)           | (null)     | (null)
1150  public  | st1     |       45 |     10000 |            45 |       45 | str     | pg_catalog          | text    |        -1 | f          |          -2 |       -2 |          -2 |        2 |        3 |        4 |        1 |        5 |     22 |     23 |     24 |     21 |     25 | {-2,22}     | {-2,23}     | {-2,24}     | {-2,21}     | {-2,25}     | (null)           | (null)     | {1,0,2}          | (null)     | (null)
1151  public  | st1     |       45 |     10000 |            45 |       45 | val     | pg_catalog          | int4    |        -1 | f          |          -1 |       -1 |          -1 |        2 |        3 |        4 |        1 |        5 |     22 |     23 |     24 |     21 |     25 | {-1,22}     | {-1,23}     | {-1,24}     | {-1,21}     | {-1,25}     | (null)           | (null)     | {1,0,2}          | (null)     | (null)
1152  public  | st1_exp |       30 |     10000 |             0 |       30 | lower   | pg_catalog          | text    |        -1 | f          |          -1 |       -1 |          -1 |        2 |        3 |        4 |        1 |        5 |     22 |     23 |     24 |     21 |     25 | {-1,22}     | {-1,23}     | {-1,24}     | {-1,21}     | {-1,25}     | (null)           | (null)     | {1,0,2}          | (null)     | (null)
1153  public  | st1_idx |       30 |     10000 |             0 |       30 |         | (null)              | (null)  |    (null) | (null)     |      (null) |   (null) |      (null) |   (null) |   (null) |   (null) |   (null) |   (null) | (null) | (null) | (null) | (null) | (null) | (null)      | (null)      | (null)      | (null)      | (null)      | (null)           | (null)     | (null)           | (null)     | (null)
1154  s0      | sft0    |        0 |         0 |             0 |        0 |         | (null)              | (null)  |    (null) | (null)     |      (null) |   (null) |      (null) |   (null) |   (null) |   (null) |   (null) |   (null) | (null) | (null) | (null) | (null) | (null) | (null)      | (null)      | (null)      | (null)      | (null)      | (null)           | (null)     | (null)           | (null)     | (null)
1155  s0      | st0     |        1 |         2 |             1 |        1 | id      | pg_catalog          | int4    |        -1 | f          |           0 |        4 |          -1 |        2 |        3 |        0 |        0 |        0 |     97 |     97 |      0 |      0 |      0 | (null)      | {1}         | (null)      | (null)      | (null)      | {1,2}            | (null)     | (null)           | (null)     | (null)
1156  s0      | st0     |        1 |         2 |             1 |        1 | id      | pg_catalog          | int4    |        -1 | t          |           0 |        4 |          -1 |        2 |        3 |        0 |        0 |        0 |     97 |     97 |      0 |      0 |      0 | (null)      | {1}         | (null)      | (null)      | (null)      | {1,2,4,5,6}      | (null)     | (null)           | (null)     | (null)
1157  s0      | st0     |        1 |         2 |             1 |        1 | num     | pg_catalog          | int4    |        -1 | f          |           0 |        4 |          -1 |        2 |        3 |        0 |        0 |        0 |     97 |     97 |      0 |      0 |      0 | (null)      | {1}         | (null)      | (null)      | (null)      | {10,20}          | (null)     | (null)           | (null)     | (null)
1158  s0      | st0     |        1 |         2 |             1 |        1 | num     | pg_catalog          | int4    |        -1 | t          |           0 |        4 |          -1 |        2 |        3 |        0 |        0 |        0 |     97 |     97 |      0 |      0 |      0 | (null)      | {1}         | (null)      | (null)      | (null)      | {10,20,40,50,60} | (null)     | (null)           | (null)     | (null)
1159  s0      | st0_idx |        2 |         2 |             0 |        2 |         | (null)              | (null)  |    (null) | (null)     |      (null) |   (null) |      (null) |   (null) |   (null) |   (null) |   (null) |   (null) | (null) | (null) | (null) | (null) | (null) | (null)      | (null)      | (null)      | (null)      | (null)      | (null)           | (null)     | (null)           | (null)     | (null)
1160  s0      | st1     |        1 |         3 |             1 |        1 | id      | pg_catalog          | int4    |        -1 | f          |          -1 |       -1 |          -1 |        2 |        3 |        4 |        1 |        5 |     22 |     23 |     24 |     21 |     25 | {-1,22}     | {-1,23}     | {-1,24}     | {-1,21}     | {-1,25}     | (null)           | (null)     | {4,5,6}          | (null)     | (null)
1161  s0      | st1     |        1 |         3 |             1 |        1 | num     | pg_catalog          | int4    |        -1 | f          |          -2 |       -2 |          -2 |        2 |        3 |        4 |        1 |        5 |     22 |     23 |     24 |     21 |     25 | {-2,22}     | {-2,23}     | {-2,24}     | {-2,21}     | {-2,25}     | (null)           | (null)     | {40,50,60}       | (null)     | (null)
1162  s0      | st1_idx |        2 |         3 |             0 |        2 |         | (null)              | (null)  |    (null) | (null)     |      (null) |   (null) |      (null) |   (null) |   (null) |   (null) |   (null) |   (null) | (null) | (null) | (null) | (null) | (null) | (null)      | (null)      | (null)      | (null)      | (null)      | (null)           | (null)     | (null)           | (null)     | (null)
1163  s0      | st2     |        1 |         3 |             1 |        1 | id      | pg_catalog          | int4    |        -1 | f          |          -1 |       -1 |          -1 |        2 |        3 |        4 |        1 |        5 |     22 |     23 |     24 |     21 |     25 | {-1,22}     | {-1,23}     | {-1,24}     | {-1,21}     | {-1,25}     | (null)           | (null)     | {1,2,3}          | (null)     | (null)
1164  s0      | st2     |        1 |         3 |             1 |        1 | txt     | pg_catalog          | text    |        -1 | f          |          -2 |       -2 |          -2 |        2 |        3 |        4 |        1 |        5 |     22 |     23 |     24 |     21 |     25 | {-2,22}     | {-2,23}     | {-2,24}     | {-2,21}     | {-2,25}     | (null)           | (null)     | {1,comment,test} | (null)     | (null)
1165  s0      | st2_idx |        2 |         3 |             0 |        2 |         | (null)              | (null)  |    (null) | (null)     |      (null) |   (null) |      (null) |   (null) |   (null) |   (null) |   (null) |   (null) | (null) | (null) | (null) | (null) | (null) | (null)      | (null)      | (null)      | (null)      | (null)      | (null)           | (null)     | (null)           | (null)     | (null)
1166  s0      | st3     |        0 |         0 |             0 |        0 |         | (null)              | (null)  |    (null) | (null)     |      (null) |   (null) |      (null) |   (null) |   (null) |   (null) |   (null) |   (null) | (null) | (null) | (null) | (null) | (null) | (null)      | (null)      | (null)      | (null)      | (null)      | (null)           | (null)     | (null)           | (null)     | (null)
1167  s1      | st0     |        1 |         4 |             1 |        1 | id      | pg_catalog          | int4    |        -1 | f          |          -1 |       -1 |          -1 |        2 |        3 |        4 |        1 |        5 |     22 |     23 |     24 |     21 |     25 | {-1,22}     | {-1,23}     | {-1,24}     | {-1,21}     | {-1,25}     | (null)           | (null)     | {1,2,3,4}        | (null)     | (null)
1168  s1      | st0     |        1 |         4 |             1 |        1 | num     | pg_catalog          | int4    |        -1 | f          |          -2 |       -2 |          -2 |        2 |        3 |        4 |        1 |        5 |     22 |     23 |     24 |     21 |     25 | {-2,22}     | {-2,23}     | {-2,24}     | {-2,21}     | {-2,25}     | (null)           | (null)     | {15,25,35,45}    | (null)     | (null)
1169 (24 rows)
1170
1171 TRUNCATE dbms_stats.work;
1172 -- No.16-2-2
1173 \! sed '/ORDER/i\\ WHERE n2.nspname = '"\'s0\'" export_effective_stats.sql.sample > export_effective_stats.sql.sample_test
1174 \i export_effective_stats.sql.sample_test
1175 /*
1176  * If you want the statistics of per-relation or per-column, please modify
1177  * nspname, relname, and attname in 'WHERE' clause.
1178  */
1179 BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE;
1180 /*
1181  * If you want to chage the output file name, please modify the following name.
1182  */
1183 \o export_stats.dmp
1184 COPY (SELECT n2.nspname,
1185              cl.relname,
1186              r.relpages,
1187              r.reltuples,
1188              r.relallvisible,
1189              r.curpages,
1190              r.last_analyze,
1191              r.last_autoanalyze,
1192              COALESCE(a.attname, ''),
1193              n1.nspname AS schemaname_of_atttype,
1194              t.typname,
1195              a.atttypmod,
1196              co.stainherit,
1197              co.stanullfrac,
1198              co.stawidth,
1199              co.stadistinct,
1200              co.stakind1,
1201              co.stakind2,
1202              co.stakind3,
1203              co.stakind4,
1204              co.stakind5,
1205              co.staop1,
1206              co.staop2,
1207              co.staop3,
1208              co.staop4,
1209              co.staop5,
1210              co.stanumbers1,
1211              co.stanumbers2,
1212              co.stanumbers3,
1213              co.stanumbers4,
1214              co.stanumbers5,
1215              co.stavalues1,
1216              co.stavalues2,
1217              co.stavalues3,
1218              co.stavalues4,
1219              co.stavalues5
1220         FROM dbms_stats.column_stats_effective co
1221         JOIN pg_attribute a
1222           ON (co.starelid = a.attrelid AND co.staattnum = a.attnum)
1223         JOIN pg_type t
1224           ON a.atttypid = t.oid
1225         JOIN pg_namespace n1
1226           ON t.typnamespace = n1.oid
1227        RIGHT JOIN dbms_stats.relation_stats_effective r
1228           ON co.starelid = r.relid
1229         JOIN pg_catalog.pg_class cl
1230           ON r.relid = cl.oid
1231         JOIN pg_catalog.pg_namespace n2
1232           ON cl.relnamespace = n2.oid
1233        -- WHERE n2.nspname = 'public'
1234        -- AND cl.relname = 'test'
1235        -- AND a.attname = 'id'
1236  WHERE n2.nspname = 's0'
1237        ORDER BY starelid, staattnum)
1238 TO STDOUT
1239 (FORMAT 'binary');
1240 \o
1241 COMMIT;
1242 COPY dbms_stats.work FROM '@abs_srcdir@/export_stats.dmp' (FORMAT 'binary');
1243 SELECT * FROM work_v;
1244  nspname | relname | relpages | reltuples | relallvisible | curpages | attname | nspname_of_typename | typname | atttypmod | stainherit | stanullfrac | stawidth | stadistinct | stakind1 | stakind2 | stakind3 | stakind4 | stakind5 | staop1 | staop2 | staop3 | staop4 | staop5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 |    stavalues1    | stavalues2 |    stavalues3    | stavalues4 | stavalues5 
1245 ---------+---------+----------+-----------+---------------+----------+---------+---------------------+---------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+-------------+-------------+-------------+-------------+-------------+------------------+------------+------------------+------------+------------
1246  s0      | sft0    |        0 |         0 |             0 |        0 |         | (null)              | (null)  |    (null) | (null)     |      (null) |   (null) |      (null) |   (null) |   (null) |   (null) |   (null) |   (null) | (null) | (null) | (null) | (null) | (null) | (null)      | (null)      | (null)      | (null)      | (null)      | (null)           | (null)     | (null)           | (null)     | (null)
1247  s0      | st0     |        1 |         2 |             1 |        1 | id      | pg_catalog          | int4    |        -1 | f          |           0 |        4 |          -1 |        2 |        3 |        0 |        0 |        0 |     97 |     97 |      0 |      0 |      0 | (null)      | {1}         | (null)      | (null)      | (null)      | {1,2}            | (null)     | (null)           | (null)     | (null)
1248  s0      | st0     |        1 |         2 |             1 |        1 | id      | pg_catalog          | int4    |        -1 | t          |           0 |        4 |          -1 |        2 |        3 |        0 |        0 |        0 |     97 |     97 |      0 |      0 |      0 | (null)      | {1}         | (null)      | (null)      | (null)      | {1,2,4,5,6}      | (null)     | (null)           | (null)     | (null)
1249  s0      | st0     |        1 |         2 |             1 |        1 | num     | pg_catalog          | int4    |        -1 | f          |           0 |        4 |          -1 |        2 |        3 |        0 |        0 |        0 |     97 |     97 |      0 |      0 |      0 | (null)      | {1}         | (null)      | (null)      | (null)      | {10,20}          | (null)     | (null)           | (null)     | (null)
1250  s0      | st0     |        1 |         2 |             1 |        1 | num     | pg_catalog          | int4    |        -1 | t          |           0 |        4 |          -1 |        2 |        3 |        0 |        0 |        0 |     97 |     97 |      0 |      0 |      0 | (null)      | {1}         | (null)      | (null)      | (null)      | {10,20,40,50,60} | (null)     | (null)           | (null)     | (null)
1251  s0      | st0_idx |        2 |         2 |             0 |        2 |         | (null)              | (null)  |    (null) | (null)     |      (null) |   (null) |      (null) |   (null) |   (null) |   (null) |   (null) |   (null) | (null) | (null) | (null) | (null) | (null) | (null)      | (null)      | (null)      | (null)      | (null)      | (null)           | (null)     | (null)           | (null)     | (null)
1252  s0      | st1     |        1 |         3 |             1 |        1 | id      | pg_catalog          | int4    |        -1 | f          |          -1 |       -1 |          -1 |        2 |        3 |        4 |        1 |        5 |     22 |     23 |     24 |     21 |     25 | {-1,22}     | {-1,23}     | {-1,24}     | {-1,21}     | {-1,25}     | (null)           | (null)     | {4,5,6}          | (null)     | (null)
1253  s0      | st1     |        1 |         3 |             1 |        1 | num     | pg_catalog          | int4    |        -1 | f          |          -2 |       -2 |          -2 |        2 |        3 |        4 |        1 |        5 |     22 |     23 |     24 |     21 |     25 | {-2,22}     | {-2,23}     | {-2,24}     | {-2,21}     | {-2,25}     | (null)           | (null)     | {40,50,60}       | (null)     | (null)
1254  s0      | st1_idx |        2 |         3 |             0 |        2 |         | (null)              | (null)  |    (null) | (null)     |      (null) |   (null) |      (null) |   (null) |   (null) |   (null) |   (null) |   (null) | (null) | (null) | (null) | (null) | (null) | (null)      | (null)      | (null)      | (null)      | (null)      | (null)           | (null)     | (null)           | (null)     | (null)
1255  s0      | st2     |        1 |         3 |             1 |        1 | id      | pg_catalog          | int4    |        -1 | f          |          -1 |       -1 |          -1 |        2 |        3 |        4 |        1 |        5 |     22 |     23 |     24 |     21 |     25 | {-1,22}     | {-1,23}     | {-1,24}     | {-1,21}     | {-1,25}     | (null)           | (null)     | {1,2,3}          | (null)     | (null)
1256  s0      | st2     |        1 |         3 |             1 |        1 | txt     | pg_catalog          | text    |        -1 | f          |          -2 |       -2 |          -2 |        2 |        3 |        4 |        1 |        5 |     22 |     23 |     24 |     21 |     25 | {-2,22}     | {-2,23}     | {-2,24}     | {-2,21}     | {-2,25}     | (null)           | (null)     | {1,comment,test} | (null)     | (null)
1257  s0      | st2_idx |        2 |         3 |             0 |        2 |         | (null)              | (null)  |    (null) | (null)     |      (null) |   (null) |      (null) |   (null) |   (null) |   (null) |   (null) |   (null) | (null) | (null) | (null) | (null) | (null) | (null)      | (null)      | (null)      | (null)      | (null)      | (null)           | (null)     | (null)           | (null)     | (null)
1258  s0      | st3     |        0 |         0 |             0 |        0 |         | (null)              | (null)  |    (null) | (null)     |      (null) |   (null) |      (null) |   (null) |   (null) |   (null) |   (null) |   (null) | (null) | (null) | (null) | (null) | (null) | (null)      | (null)      | (null)      | (null)      | (null)      | (null)           | (null)     | (null)           | (null)     | (null)
1259 (13 rows)
1260
1261 \! rm export_effective_stats.sql.sample_test
1262 TRUNCATE dbms_stats.work;
1263 -- No.16-2-3
1264 \! sed '/ORDER/i\\ WHERE cl.relname = '"\'st0\'" export_effective_stats.sql.sample > export_effective_stats.sql.sample_test
1265 \i export_effective_stats.sql.sample_test
1266 /*
1267  * If you want the statistics of per-relation or per-column, please modify
1268  * nspname, relname, and attname in 'WHERE' clause.
1269  */
1270 BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE;
1271 /*
1272  * If you want to chage the output file name, please modify the following name.
1273  */
1274 \o export_stats.dmp
1275 COPY (SELECT n2.nspname,
1276              cl.relname,
1277              r.relpages,
1278              r.reltuples,
1279              r.relallvisible,
1280              r.curpages,
1281              r.last_analyze,
1282              r.last_autoanalyze,
1283              COALESCE(a.attname, ''),
1284              n1.nspname AS schemaname_of_atttype,
1285              t.typname,
1286              a.atttypmod,
1287              co.stainherit,
1288              co.stanullfrac,
1289              co.stawidth,
1290              co.stadistinct,
1291              co.stakind1,
1292              co.stakind2,
1293              co.stakind3,
1294              co.stakind4,
1295              co.stakind5,
1296              co.staop1,
1297              co.staop2,
1298              co.staop3,
1299              co.staop4,
1300              co.staop5,
1301              co.stanumbers1,
1302              co.stanumbers2,
1303              co.stanumbers3,
1304              co.stanumbers4,
1305              co.stanumbers5,
1306              co.stavalues1,
1307              co.stavalues2,
1308              co.stavalues3,
1309              co.stavalues4,
1310              co.stavalues5
1311         FROM dbms_stats.column_stats_effective co
1312         JOIN pg_attribute a
1313           ON (co.starelid = a.attrelid AND co.staattnum = a.attnum)
1314         JOIN pg_type t
1315           ON a.atttypid = t.oid
1316         JOIN pg_namespace n1
1317           ON t.typnamespace = n1.oid
1318        RIGHT JOIN dbms_stats.relation_stats_effective r
1319           ON co.starelid = r.relid
1320         JOIN pg_catalog.pg_class cl
1321           ON r.relid = cl.oid
1322         JOIN pg_catalog.pg_namespace n2
1323           ON cl.relnamespace = n2.oid
1324        -- WHERE n2.nspname = 'public'
1325        -- AND cl.relname = 'test'
1326        -- AND a.attname = 'id'
1327  WHERE cl.relname = 'st0'
1328        ORDER BY starelid, staattnum)
1329 TO STDOUT
1330 (FORMAT 'binary');
1331 \o
1332 COMMIT;
1333 COPY dbms_stats.work FROM '@abs_srcdir@/export_stats.dmp' (FORMAT 'binary');
1334 SELECT * FROM work_v;
1335  nspname | relname | relpages | reltuples | relallvisible | curpages | attname | nspname_of_typename | typname | atttypmod | stainherit | stanullfrac | stawidth | stadistinct | stakind1 | stakind2 | stakind3 | stakind4 | stakind5 | staop1 | staop2 | staop3 | staop4 | staop5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 |    stavalues1    | stavalues2 |  stavalues3   | stavalues4 | stavalues5 
1336 ---------+---------+----------+-----------+---------------+----------+---------+---------------------+---------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+-------------+-------------+-------------+-------------+-------------+------------------+------------+---------------+------------+------------
1337  public  | st0     |        1 |         2 |             1 |        1 | id      | pg_catalog          | int4    |        -1 | f          |          -1 |       -1 |          -1 |        2 |        3 |        4 |        1 |        5 |     22 |     23 |     24 |     21 |     25 | {-1,22}     | {-1,23}     | {-1,24}     | {-1,21}     | {-1,25}     | (null)           | (null)     | {1,2}         | (null)     | (null)
1338  public  | st0     |        1 |         2 |             1 |        1 | name    | pg_catalog          | bpchar  |         9 | f          |          -2 |       -2 |          -2 |        2 |        3 |        4 |        1 |        5 |     22 |     23 |     24 |     21 |     25 | {-2,22}     | {-2,23}     | {-2,24}     | {-2,21}     | {-2,25}     | (null)           | (null)     | {"test "}     | (null)     | (null)
1339  s0      | st0     |        1 |         2 |             1 |        1 | id      | pg_catalog          | int4    |        -1 | f          |           0 |        4 |          -1 |        2 |        3 |        0 |        0 |        0 |     97 |     97 |      0 |      0 |      0 | (null)      | {1}         | (null)      | (null)      | (null)      | {1,2}            | (null)     | (null)        | (null)     | (null)
1340  s0      | st0     |        1 |         2 |             1 |        1 | id      | pg_catalog          | int4    |        -1 | t          |           0 |        4 |          -1 |        2 |        3 |        0 |        0 |        0 |     97 |     97 |      0 |      0 |      0 | (null)      | {1}         | (null)      | (null)      | (null)      | {1,2,4,5,6}      | (null)     | (null)        | (null)     | (null)
1341  s0      | st0     |        1 |         2 |             1 |        1 | num     | pg_catalog          | int4    |        -1 | f          |           0 |        4 |          -1 |        2 |        3 |        0 |        0 |        0 |     97 |     97 |      0 |      0 |      0 | (null)      | {1}         | (null)      | (null)      | (null)      | {10,20}          | (null)     | (null)        | (null)     | (null)
1342  s0      | st0     |        1 |         2 |             1 |        1 | num     | pg_catalog          | int4    |        -1 | t          |           0 |        4 |          -1 |        2 |        3 |        0 |        0 |        0 |     97 |     97 |      0 |      0 |      0 | (null)      | {1}         | (null)      | (null)      | (null)      | {10,20,40,50,60} | (null)     | (null)        | (null)     | (null)
1343  s1      | st0     |        1 |         4 |             1 |        1 | id      | pg_catalog          | int4    |        -1 | f          |          -1 |       -1 |          -1 |        2 |        3 |        4 |        1 |        5 |     22 |     23 |     24 |     21 |     25 | {-1,22}     | {-1,23}     | {-1,24}     | {-1,21}     | {-1,25}     | (null)           | (null)     | {1,2,3,4}     | (null)     | (null)
1344  s1      | st0     |        1 |         4 |             1 |        1 | num     | pg_catalog          | int4    |        -1 | f          |          -2 |       -2 |          -2 |        2 |        3 |        4 |        1 |        5 |     22 |     23 |     24 |     21 |     25 | {-2,22}     | {-2,23}     | {-2,24}     | {-2,21}     | {-2,25}     | (null)           | (null)     | {15,25,35,45} | (null)     | (null)
1345 (8 rows)
1346
1347 \! rm export_effective_stats.sql.sample_test
1348 TRUNCATE dbms_stats.work;
1349 -- No.16-2-4
1350 \! sed '/ORDER/i\\ WHERE cl.relname = '"\'pg_toast_1262\'" export_effective_stats.sql.sample > export_effective_stats.sql.sample_test
1351 \i export_effective_stats.sql.sample_test
1352 /*
1353  * If you want the statistics of per-relation or per-column, please modify
1354  * nspname, relname, and attname in 'WHERE' clause.
1355  */
1356 BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE;
1357 /*
1358  * If you want to chage the output file name, please modify the following name.
1359  */
1360 \o export_stats.dmp
1361 COPY (SELECT n2.nspname,
1362              cl.relname,
1363              r.relpages,
1364              r.reltuples,
1365              r.relallvisible,
1366              r.curpages,
1367              r.last_analyze,
1368              r.last_autoanalyze,
1369              COALESCE(a.attname, ''),
1370              n1.nspname AS schemaname_of_atttype,
1371              t.typname,
1372              a.atttypmod,
1373              co.stainherit,
1374              co.stanullfrac,
1375              co.stawidth,
1376              co.stadistinct,
1377              co.stakind1,
1378              co.stakind2,
1379              co.stakind3,
1380              co.stakind4,
1381              co.stakind5,
1382              co.staop1,
1383              co.staop2,
1384              co.staop3,
1385              co.staop4,
1386              co.staop5,
1387              co.stanumbers1,
1388              co.stanumbers2,
1389              co.stanumbers3,
1390              co.stanumbers4,
1391              co.stanumbers5,
1392              co.stavalues1,
1393              co.stavalues2,
1394              co.stavalues3,
1395              co.stavalues4,
1396              co.stavalues5
1397         FROM dbms_stats.column_stats_effective co
1398         JOIN pg_attribute a
1399           ON (co.starelid = a.attrelid AND co.staattnum = a.attnum)
1400         JOIN pg_type t
1401           ON a.atttypid = t.oid
1402         JOIN pg_namespace n1
1403           ON t.typnamespace = n1.oid
1404        RIGHT JOIN dbms_stats.relation_stats_effective r
1405           ON co.starelid = r.relid
1406         JOIN pg_catalog.pg_class cl
1407           ON r.relid = cl.oid
1408         JOIN pg_catalog.pg_namespace n2
1409           ON cl.relnamespace = n2.oid
1410        -- WHERE n2.nspname = 'public'
1411        -- AND cl.relname = 'test'
1412        -- AND a.attname = 'id'
1413  WHERE cl.relname = 'pg_toast_1262'
1414        ORDER BY starelid, staattnum)
1415 TO STDOUT
1416 (FORMAT 'binary');
1417 \o
1418 COMMIT;
1419 COPY dbms_stats.work FROM '@abs_srcdir@/export_stats.dmp' (FORMAT 'binary');
1420 SELECT * FROM work_v;
1421  nspname | relname | relpages | reltuples | relallvisible | curpages | attname | nspname_of_typename | typname | atttypmod | stainherit | stanullfrac | stawidth | stadistinct | stakind1 | stakind2 | stakind3 | stakind4 | stakind5 | staop1 | staop2 | staop3 | staop4 | staop5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1 | stavalues2 | stavalues3 | stavalues4 | stavalues5 
1422 ---------+---------+----------+-----------+---------------+----------+---------+---------------------+---------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+-------------+-------------+-------------+-------------+-------------+------------+------------+------------+------------+------------
1423 (0 rows)
1424
1425 \! rm export_effective_stats.sql.sample_test
1426 TRUNCATE dbms_stats.work;
1427 -- No.16-2-5
1428 \! sed '/ORDER/i\\ WHERE cl.relname = '"\'st0_idx\'" export_effective_stats.sql.sample > export_effective_stats.sql.sample_test
1429 \i export_effective_stats.sql.sample_test
1430 /*
1431  * If you want the statistics of per-relation or per-column, please modify
1432  * nspname, relname, and attname in 'WHERE' clause.
1433  */
1434 BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE;
1435 /*
1436  * If you want to chage the output file name, please modify the following name.
1437  */
1438 \o export_stats.dmp
1439 COPY (SELECT n2.nspname,
1440              cl.relname,
1441              r.relpages,
1442              r.reltuples,
1443              r.relallvisible,
1444              r.curpages,
1445              r.last_analyze,
1446              r.last_autoanalyze,
1447              COALESCE(a.attname, ''),
1448              n1.nspname AS schemaname_of_atttype,
1449              t.typname,
1450              a.atttypmod,
1451              co.stainherit,
1452              co.stanullfrac,
1453              co.stawidth,
1454              co.stadistinct,
1455              co.stakind1,
1456              co.stakind2,
1457              co.stakind3,
1458              co.stakind4,
1459              co.stakind5,
1460              co.staop1,
1461              co.staop2,
1462              co.staop3,
1463              co.staop4,
1464              co.staop5,
1465              co.stanumbers1,
1466              co.stanumbers2,
1467              co.stanumbers3,
1468              co.stanumbers4,
1469              co.stanumbers5,
1470              co.stavalues1,
1471              co.stavalues2,
1472              co.stavalues3,
1473              co.stavalues4,
1474              co.stavalues5
1475         FROM dbms_stats.column_stats_effective co
1476         JOIN pg_attribute a
1477           ON (co.starelid = a.attrelid AND co.staattnum = a.attnum)
1478         JOIN pg_type t
1479           ON a.atttypid = t.oid
1480         JOIN pg_namespace n1
1481           ON t.typnamespace = n1.oid
1482        RIGHT JOIN dbms_stats.relation_stats_effective r
1483           ON co.starelid = r.relid
1484         JOIN pg_catalog.pg_class cl
1485           ON r.relid = cl.oid
1486         JOIN pg_catalog.pg_namespace n2
1487           ON cl.relnamespace = n2.oid
1488        -- WHERE n2.nspname = 'public'
1489        -- AND cl.relname = 'test'
1490        -- AND a.attname = 'id'
1491  WHERE cl.relname = 'st0_idx'
1492        ORDER BY starelid, staattnum)
1493 TO STDOUT
1494 (FORMAT 'binary');
1495 \o
1496 COMMIT;
1497 COPY dbms_stats.work FROM '@abs_srcdir@/export_stats.dmp' (FORMAT 'binary');
1498 SELECT * FROM work_v;
1499  nspname | relname | relpages | reltuples | relallvisible | curpages | attname | nspname_of_typename | typname | atttypmod | stainherit | stanullfrac | stawidth | stadistinct | stakind1 | stakind2 | stakind3 | stakind4 | stakind5 | staop1 | staop2 | staop3 | staop4 | staop5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1 | stavalues2 | stavalues3 | stavalues4 | stavalues5 
1500 ---------+---------+----------+-----------+---------------+----------+---------+---------------------+---------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+-------------+-------------+-------------+-------------+-------------+------------+------------+------------+------------+------------
1501  public  | st0_idx |        2 |         2 |             0 |        2 |         | (null)              | (null)  |    (null) | (null)     |      (null) |   (null) |      (null) |   (null) |   (null) |   (null) |   (null) |   (null) | (null) | (null) | (null) | (null) | (null) | (null)      | (null)      | (null)      | (null)      | (null)      | (null)     | (null)     | (null)     | (null)     | (null)
1502  s0      | st0_idx |        2 |         2 |             0 |        2 |         | (null)              | (null)  |    (null) | (null)     |      (null) |   (null) |      (null) |   (null) |   (null) |   (null) |   (null) |   (null) | (null) | (null) | (null) | (null) | (null) | (null)      | (null)      | (null)      | (null)      | (null)      | (null)     | (null)     | (null)     | (null)     | (null)
1503 (2 rows)
1504
1505 \! rm export_effective_stats.sql.sample_test
1506 TRUNCATE dbms_stats.work;
1507 -- No.16-2-6
1508 \! sed '/ORDER/i\\ WHERE cl.relname = '"\'ss0\'" export_effective_stats.sql.sample > export_effective_stats.sql.sample_test
1509 \i export_effective_stats.sql.sample_test
1510 /*
1511  * If you want the statistics of per-relation or per-column, please modify
1512  * nspname, relname, and attname in 'WHERE' clause.
1513  */
1514 BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE;
1515 /*
1516  * If you want to chage the output file name, please modify the following name.
1517  */
1518 \o export_stats.dmp
1519 COPY (SELECT n2.nspname,
1520              cl.relname,
1521              r.relpages,
1522              r.reltuples,
1523              r.relallvisible,
1524              r.curpages,
1525              r.last_analyze,
1526              r.last_autoanalyze,
1527              COALESCE(a.attname, ''),
1528              n1.nspname AS schemaname_of_atttype,
1529              t.typname,
1530              a.atttypmod,
1531              co.stainherit,
1532              co.stanullfrac,
1533              co.stawidth,
1534              co.stadistinct,
1535              co.stakind1,
1536              co.stakind2,
1537              co.stakind3,
1538              co.stakind4,
1539              co.stakind5,
1540              co.staop1,
1541              co.staop2,
1542              co.staop3,
1543              co.staop4,
1544              co.staop5,
1545              co.stanumbers1,
1546              co.stanumbers2,
1547              co.stanumbers3,
1548              co.stanumbers4,
1549              co.stanumbers5,
1550              co.stavalues1,
1551              co.stavalues2,
1552              co.stavalues3,
1553              co.stavalues4,
1554              co.stavalues5
1555         FROM dbms_stats.column_stats_effective co
1556         JOIN pg_attribute a
1557           ON (co.starelid = a.attrelid AND co.staattnum = a.attnum)
1558         JOIN pg_type t
1559           ON a.atttypid = t.oid
1560         JOIN pg_namespace n1
1561           ON t.typnamespace = n1.oid
1562        RIGHT JOIN dbms_stats.relation_stats_effective r
1563           ON co.starelid = r.relid
1564         JOIN pg_catalog.pg_class cl
1565           ON r.relid = cl.oid
1566         JOIN pg_catalog.pg_namespace n2
1567           ON cl.relnamespace = n2.oid
1568        -- WHERE n2.nspname = 'public'
1569        -- AND cl.relname = 'test'
1570        -- AND a.attname = 'id'
1571  WHERE cl.relname = 'ss0'
1572        ORDER BY starelid, staattnum)
1573 TO STDOUT
1574 (FORMAT 'binary');
1575 \o
1576 COMMIT;
1577 COPY dbms_stats.work FROM '@abs_srcdir@/export_stats.dmp' (FORMAT 'binary');
1578 SELECT * FROM work_v;
1579  nspname | relname | relpages | reltuples | relallvisible | curpages | attname | nspname_of_typename | typname | atttypmod | stainherit | stanullfrac | stawidth | stadistinct | stakind1 | stakind2 | stakind3 | stakind4 | stakind5 | staop1 | staop2 | staop3 | staop4 | staop5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1 | stavalues2 | stavalues3 | stavalues4 | stavalues5 
1580 ---------+---------+----------+-----------+---------------+----------+---------+---------------------+---------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+-------------+-------------+-------------+-------------+-------------+------------+------------+------------+------------+------------
1581 (0 rows)
1582
1583 \! rm export_effective_stats.sql.sample_test
1584 TRUNCATE dbms_stats.work;
1585 -- No.16-2-7
1586 \! sed '/ORDER/i\\ WHERE cl.relname = '"\'sc0\'" export_effective_stats.sql.sample > export_effective_stats.sql.sample_test
1587 \i export_effective_stats.sql.sample_test
1588 /*
1589  * If you want the statistics of per-relation or per-column, please modify
1590  * nspname, relname, and attname in 'WHERE' clause.
1591  */
1592 BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE;
1593 /*
1594  * If you want to chage the output file name, please modify the following name.
1595  */
1596 \o export_stats.dmp
1597 COPY (SELECT n2.nspname,
1598              cl.relname,
1599              r.relpages,
1600              r.reltuples,
1601              r.relallvisible,
1602              r.curpages,
1603              r.last_analyze,
1604              r.last_autoanalyze,
1605              COALESCE(a.attname, ''),
1606              n1.nspname AS schemaname_of_atttype,
1607              t.typname,
1608              a.atttypmod,
1609              co.stainherit,
1610              co.stanullfrac,
1611              co.stawidth,
1612              co.stadistinct,
1613              co.stakind1,
1614              co.stakind2,
1615              co.stakind3,
1616              co.stakind4,
1617              co.stakind5,
1618              co.staop1,
1619              co.staop2,
1620              co.staop3,
1621              co.staop4,
1622              co.staop5,
1623              co.stanumbers1,
1624              co.stanumbers2,
1625              co.stanumbers3,
1626              co.stanumbers4,
1627              co.stanumbers5,
1628              co.stavalues1,
1629              co.stavalues2,
1630              co.stavalues3,
1631              co.stavalues4,
1632              co.stavalues5
1633         FROM dbms_stats.column_stats_effective co
1634         JOIN pg_attribute a
1635           ON (co.starelid = a.attrelid AND co.staattnum = a.attnum)
1636         JOIN pg_type t
1637           ON a.atttypid = t.oid
1638         JOIN pg_namespace n1
1639           ON t.typnamespace = n1.oid
1640        RIGHT JOIN dbms_stats.relation_stats_effective r
1641           ON co.starelid = r.relid
1642         JOIN pg_catalog.pg_class cl
1643           ON r.relid = cl.oid
1644         JOIN pg_catalog.pg_namespace n2
1645           ON cl.relnamespace = n2.oid
1646        -- WHERE n2.nspname = 'public'
1647        -- AND cl.relname = 'test'
1648        -- AND a.attname = 'id'
1649  WHERE cl.relname = 'sc0'
1650        ORDER BY starelid, staattnum)
1651 TO STDOUT
1652 (FORMAT 'binary');
1653 \o
1654 COMMIT;
1655 COPY dbms_stats.work FROM '@abs_srcdir@/export_stats.dmp' (FORMAT 'binary');
1656 SELECT * FROM work_v;
1657  nspname | relname | relpages | reltuples | relallvisible | curpages | attname | nspname_of_typename | typname | atttypmod | stainherit | stanullfrac | stawidth | stadistinct | stakind1 | stakind2 | stakind3 | stakind4 | stakind5 | staop1 | staop2 | staop3 | staop4 | staop5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1 | stavalues2 | stavalues3 | stavalues4 | stavalues5 
1658 ---------+---------+----------+-----------+---------------+----------+---------+---------------------+---------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+-------------+-------------+-------------+-------------+-------------+------------+------------+------------+------------+------------
1659 (0 rows)
1660
1661 \! rm export_effective_stats.sql.sample_test
1662 TRUNCATE dbms_stats.work;
1663 -- No.16-2-8
1664 \! sed '/ORDER/i\\ WHERE cl.relname = '"\'sft0\'" export_effective_stats.sql.sample > export_effective_stats.sql.sample_test
1665 \i export_effective_stats.sql.sample_test
1666 /*
1667  * If you want the statistics of per-relation or per-column, please modify
1668  * nspname, relname, and attname in 'WHERE' clause.
1669  */
1670 BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE;
1671 /*
1672  * If you want to chage the output file name, please modify the following name.
1673  */
1674 \o export_stats.dmp
1675 COPY (SELECT n2.nspname,
1676              cl.relname,
1677              r.relpages,
1678              r.reltuples,
1679              r.relallvisible,
1680              r.curpages,
1681              r.last_analyze,
1682              r.last_autoanalyze,
1683              COALESCE(a.attname, ''),
1684              n1.nspname AS schemaname_of_atttype,
1685              t.typname,
1686              a.atttypmod,
1687              co.stainherit,
1688              co.stanullfrac,
1689              co.stawidth,
1690              co.stadistinct,
1691              co.stakind1,
1692              co.stakind2,
1693              co.stakind3,
1694              co.stakind4,
1695              co.stakind5,
1696              co.staop1,
1697              co.staop2,
1698              co.staop3,
1699              co.staop4,
1700              co.staop5,
1701              co.stanumbers1,
1702              co.stanumbers2,
1703              co.stanumbers3,
1704              co.stanumbers4,
1705              co.stanumbers5,
1706              co.stavalues1,
1707              co.stavalues2,
1708              co.stavalues3,
1709              co.stavalues4,
1710              co.stavalues5
1711         FROM dbms_stats.column_stats_effective co
1712         JOIN pg_attribute a
1713           ON (co.starelid = a.attrelid AND co.staattnum = a.attnum)
1714         JOIN pg_type t
1715           ON a.atttypid = t.oid
1716         JOIN pg_namespace n1
1717           ON t.typnamespace = n1.oid
1718        RIGHT JOIN dbms_stats.relation_stats_effective r
1719           ON co.starelid = r.relid
1720         JOIN pg_catalog.pg_class cl
1721           ON r.relid = cl.oid
1722         JOIN pg_catalog.pg_namespace n2
1723           ON cl.relnamespace = n2.oid
1724        -- WHERE n2.nspname = 'public'
1725        -- AND cl.relname = 'test'
1726        -- AND a.attname = 'id'
1727  WHERE cl.relname = 'sft0'
1728        ORDER BY starelid, staattnum)
1729 TO STDOUT
1730 (FORMAT 'binary');
1731 \o
1732 COMMIT;
1733 COPY dbms_stats.work FROM '@abs_srcdir@/export_stats.dmp' (FORMAT 'binary');
1734 SELECT * FROM work_v;
1735  nspname | relname | relpages | reltuples | relallvisible | curpages | attname | nspname_of_typename | typname | atttypmod | stainherit | stanullfrac | stawidth | stadistinct | stakind1 | stakind2 | stakind3 | stakind4 | stakind5 | staop1 | staop2 | staop3 | staop4 | staop5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1 | stavalues2 | stavalues3 | stavalues4 | stavalues5 
1736 ---------+---------+----------+-----------+---------------+----------+---------+---------------------+---------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+-------------+-------------+-------------+-------------+-------------+------------+------------+------------+------------+------------
1737  s0      | sft0    |        0 |         0 |             0 |        0 |         | (null)              | (null)  |    (null) | (null)     |      (null) |   (null) |      (null) |   (null) |   (null) |   (null) |   (null) |   (null) | (null) | (null) | (null) | (null) | (null) | (null)      | (null)      | (null)      | (null)      | (null)      | (null)     | (null)     | (null)     | (null)     | (null)
1738 (1 row)
1739
1740 \! rm export_effective_stats.sql.sample_test
1741 TRUNCATE dbms_stats.work;
1742 -- No.16-2-9
1743 \! sed '/ORDER/i\\ WHERE n2.nspname = '"\'s0\'"' AND a.attname = '"\'id\'" export_effective_stats.sql.sample > export_effective_stats.sql.sample_test
1744 \i export_effective_stats.sql.sample_test
1745 /*
1746  * If you want the statistics of per-relation or per-column, please modify
1747  * nspname, relname, and attname in 'WHERE' clause.
1748  */
1749 BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE;
1750 /*
1751  * If you want to chage the output file name, please modify the following name.
1752  */
1753 \o export_stats.dmp
1754 COPY (SELECT n2.nspname,
1755              cl.relname,
1756              r.relpages,
1757              r.reltuples,
1758              r.relallvisible,
1759              r.curpages,
1760              r.last_analyze,
1761              r.last_autoanalyze,
1762              COALESCE(a.attname, ''),
1763              n1.nspname AS schemaname_of_atttype,
1764              t.typname,
1765              a.atttypmod,
1766              co.stainherit,
1767              co.stanullfrac,
1768              co.stawidth,
1769              co.stadistinct,
1770              co.stakind1,
1771              co.stakind2,
1772              co.stakind3,
1773              co.stakind4,
1774              co.stakind5,
1775              co.staop1,
1776              co.staop2,
1777              co.staop3,
1778              co.staop4,
1779              co.staop5,
1780              co.stanumbers1,
1781              co.stanumbers2,
1782              co.stanumbers3,
1783              co.stanumbers4,
1784              co.stanumbers5,
1785              co.stavalues1,
1786              co.stavalues2,
1787              co.stavalues3,
1788              co.stavalues4,
1789              co.stavalues5
1790         FROM dbms_stats.column_stats_effective co
1791         JOIN pg_attribute a
1792           ON (co.starelid = a.attrelid AND co.staattnum = a.attnum)
1793         JOIN pg_type t
1794           ON a.atttypid = t.oid
1795         JOIN pg_namespace n1
1796           ON t.typnamespace = n1.oid
1797        RIGHT JOIN dbms_stats.relation_stats_effective r
1798           ON co.starelid = r.relid
1799         JOIN pg_catalog.pg_class cl
1800           ON r.relid = cl.oid
1801         JOIN pg_catalog.pg_namespace n2
1802           ON cl.relnamespace = n2.oid
1803        -- WHERE n2.nspname = 'public'
1804        -- AND cl.relname = 'test'
1805        -- AND a.attname = 'id'
1806  WHERE n2.nspname = 's0' AND a.attname = 'id'
1807        ORDER BY starelid, staattnum)
1808 TO STDOUT
1809 (FORMAT 'binary');
1810 \o
1811 COMMIT;
1812 COPY dbms_stats.work FROM '@abs_srcdir@/export_stats.dmp' (FORMAT 'binary');
1813 SELECT * FROM work_v;
1814  nspname | relname | relpages | reltuples | relallvisible | curpages | attname | nspname_of_typename | typname | atttypmod | stainherit | stanullfrac | stawidth | stadistinct | stakind1 | stakind2 | stakind3 | stakind4 | stakind5 | staop1 | staop2 | staop3 | staop4 | staop5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1  | stavalues2 | stavalues3 | stavalues4 | stavalues5 
1815 ---------+---------+----------+-----------+---------------+----------+---------+---------------------+---------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+-------------+-------------+-------------+-------------+-------------+-------------+------------+------------+------------+------------
1816  s0      | st0     |        1 |         2 |             1 |        1 | id      | pg_catalog          | int4    |        -1 | f          |           0 |        4 |          -1 |        2 |        3 |        0 |        0 |        0 |     97 |     97 |      0 |      0 |      0 | (null)      | {1}         | (null)      | (null)      | (null)      | {1,2}       | (null)     | (null)     | (null)     | (null)
1817  s0      | st0     |        1 |         2 |             1 |        1 | id      | pg_catalog          | int4    |        -1 | t          |           0 |        4 |          -1 |        2 |        3 |        0 |        0 |        0 |     97 |     97 |      0 |      0 |      0 | (null)      | {1}         | (null)      | (null)      | (null)      | {1,2,4,5,6} | (null)     | (null)     | (null)     | (null)
1818  s0      | st1     |        1 |         3 |             1 |        1 | id      | pg_catalog          | int4    |        -1 | f          |          -1 |       -1 |          -1 |        2 |        3 |        4 |        1 |        5 |     22 |     23 |     24 |     21 |     25 | {-1,22}     | {-1,23}     | {-1,24}     | {-1,21}     | {-1,25}     | (null)      | (null)     | {4,5,6}    | (null)     | (null)
1819  s0      | st2     |        1 |         3 |             1 |        1 | id      | pg_catalog          | int4    |        -1 | f          |          -1 |       -1 |          -1 |        2 |        3 |        4 |        1 |        5 |     22 |     23 |     24 |     21 |     25 | {-1,22}     | {-1,23}     | {-1,24}     | {-1,21}     | {-1,25}     | (null)      | (null)     | {1,2,3}    | (null)     | (null)
1820 (4 rows)
1821
1822 \! rm export_effective_stats.sql.sample_test
1823 TRUNCATE dbms_stats.work;
1824 -- No.16-2-10
1825 \! sed '/ORDER/i\\ WHERE n2.nspname = '"\'s0\'"' AND a.attname IS NULL' export_effective_stats.sql.sample > export_effective_stats.sql.sample_test
1826 \i export_effective_stats.sql.sample_test
1827 /*
1828  * If you want the statistics of per-relation or per-column, please modify
1829  * nspname, relname, and attname in 'WHERE' clause.
1830  */
1831 BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE;
1832 /*
1833  * If you want to chage the output file name, please modify the following name.
1834  */
1835 \o export_stats.dmp
1836 COPY (SELECT n2.nspname,
1837              cl.relname,
1838              r.relpages,
1839              r.reltuples,
1840              r.relallvisible,
1841              r.curpages,
1842              r.last_analyze,
1843              r.last_autoanalyze,
1844              COALESCE(a.attname, ''),
1845              n1.nspname AS schemaname_of_atttype,
1846              t.typname,
1847              a.atttypmod,
1848              co.stainherit,
1849              co.stanullfrac,
1850              co.stawidth,
1851              co.stadistinct,
1852              co.stakind1,
1853              co.stakind2,
1854              co.stakind3,
1855              co.stakind4,
1856              co.stakind5,
1857              co.staop1,
1858              co.staop2,
1859              co.staop3,
1860              co.staop4,
1861              co.staop5,
1862              co.stanumbers1,
1863              co.stanumbers2,
1864              co.stanumbers3,
1865              co.stanumbers4,
1866              co.stanumbers5,
1867              co.stavalues1,
1868              co.stavalues2,
1869              co.stavalues3,
1870              co.stavalues4,
1871              co.stavalues5
1872         FROM dbms_stats.column_stats_effective co
1873         JOIN pg_attribute a
1874           ON (co.starelid = a.attrelid AND co.staattnum = a.attnum)
1875         JOIN pg_type t
1876           ON a.atttypid = t.oid
1877         JOIN pg_namespace n1
1878           ON t.typnamespace = n1.oid
1879        RIGHT JOIN dbms_stats.relation_stats_effective r
1880           ON co.starelid = r.relid
1881         JOIN pg_catalog.pg_class cl
1882           ON r.relid = cl.oid
1883         JOIN pg_catalog.pg_namespace n2
1884           ON cl.relnamespace = n2.oid
1885        -- WHERE n2.nspname = 'public'
1886        -- AND cl.relname = 'test'
1887        -- AND a.attname = 'id'
1888  WHERE n2.nspname = 's0' AND a.attname IS NULL
1889        ORDER BY starelid, staattnum)
1890 TO STDOUT
1891 (FORMAT 'binary');
1892 \o
1893 COMMIT;
1894 COPY dbms_stats.work FROM '@abs_srcdir@/export_stats.dmp' (FORMAT 'binary');
1895 SELECT * FROM work_v;
1896  nspname | relname | relpages | reltuples | relallvisible | curpages | attname | nspname_of_typename | typname | atttypmod | stainherit | stanullfrac | stawidth | stadistinct | stakind1 | stakind2 | stakind3 | stakind4 | stakind5 | staop1 | staop2 | staop3 | staop4 | staop5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1 | stavalues2 | stavalues3 | stavalues4 | stavalues5 
1897 ---------+---------+----------+-----------+---------------+----------+---------+---------------------+---------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+-------------+-------------+-------------+-------------+-------------+------------+------------+------------+------------+------------
1898  s0      | sft0    |        0 |         0 |             0 |        0 |         | (null)              | (null)  |    (null) | (null)     |      (null) |   (null) |      (null) |   (null) |   (null) |   (null) |   (null) |   (null) | (null) | (null) | (null) | (null) | (null) | (null)      | (null)      | (null)      | (null)      | (null)      | (null)     | (null)     | (null)     | (null)     | (null)
1899  s0      | st0_idx |        2 |         2 |             0 |        2 |         | (null)              | (null)  |    (null) | (null)     |      (null) |   (null) |      (null) |   (null) |   (null) |   (null) |   (null) |   (null) | (null) | (null) | (null) | (null) | (null) | (null)      | (null)      | (null)      | (null)      | (null)      | (null)     | (null)     | (null)     | (null)     | (null)
1900  s0      | st1_idx |        2 |         3 |             0 |        2 |         | (null)              | (null)  |    (null) | (null)     |      (null) |   (null) |      (null) |   (null) |   (null) |   (null) |   (null) |   (null) | (null) | (null) | (null) | (null) | (null) | (null)      | (null)      | (null)      | (null)      | (null)      | (null)     | (null)     | (null)     | (null)     | (null)
1901  s0      | st2_idx |        2 |         3 |             0 |        2 |         | (null)              | (null)  |    (null) | (null)     |      (null) |   (null) |      (null) |   (null) |   (null) |   (null) |   (null) |   (null) | (null) | (null) | (null) | (null) | (null) | (null)      | (null)      | (null)      | (null)      | (null)      | (null)     | (null)     | (null)     | (null)     | (null)
1902  s0      | st3     |        0 |         0 |             0 |        0 |         | (null)              | (null)  |    (null) | (null)     |      (null) |   (null) |      (null) |   (null) |   (null) |   (null) |   (null) |   (null) | (null) | (null) | (null) | (null) | (null) | (null)      | (null)      | (null)      | (null)      | (null)      | (null)     | (null)     | (null)     | (null)     | (null)
1903 (5 rows)
1904
1905 \! rm export_effective_stats.sql.sample_test
1906 TRUNCATE dbms_stats.work;
1907 -- No.16-2-11
1908 \! sed '/ORDER/i\\ WHERE n2.nspname = '"\'s0\'"' AND cl.relname IS NULL' export_effective_stats.sql.sample > export_effective_stats.sql.sample_test
1909 \i export_effective_stats.sql.sample_test
1910 /*
1911  * If you want the statistics of per-relation or per-column, please modify
1912  * nspname, relname, and attname in 'WHERE' clause.
1913  */
1914 BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE;
1915 /*
1916  * If you want to chage the output file name, please modify the following name.
1917  */
1918 \o export_stats.dmp
1919 COPY (SELECT n2.nspname,
1920              cl.relname,
1921              r.relpages,
1922              r.reltuples,
1923              r.relallvisible,
1924              r.curpages,
1925              r.last_analyze,
1926              r.last_autoanalyze,
1927              COALESCE(a.attname, ''),
1928              n1.nspname AS schemaname_of_atttype,
1929              t.typname,
1930              a.atttypmod,
1931              co.stainherit,
1932              co.stanullfrac,
1933              co.stawidth,
1934              co.stadistinct,
1935              co.stakind1,
1936              co.stakind2,
1937              co.stakind3,
1938              co.stakind4,
1939              co.stakind5,
1940              co.staop1,
1941              co.staop2,
1942              co.staop3,
1943              co.staop4,
1944              co.staop5,
1945              co.stanumbers1,
1946              co.stanumbers2,
1947              co.stanumbers3,
1948              co.stanumbers4,
1949              co.stanumbers5,
1950              co.stavalues1,
1951              co.stavalues2,
1952              co.stavalues3,
1953              co.stavalues4,
1954              co.stavalues5
1955         FROM dbms_stats.column_stats_effective co
1956         JOIN pg_attribute a
1957           ON (co.starelid = a.attrelid AND co.staattnum = a.attnum)
1958         JOIN pg_type t
1959           ON a.atttypid = t.oid
1960         JOIN pg_namespace n1
1961           ON t.typnamespace = n1.oid
1962        RIGHT JOIN dbms_stats.relation_stats_effective r
1963           ON co.starelid = r.relid
1964         JOIN pg_catalog.pg_class cl
1965           ON r.relid = cl.oid
1966         JOIN pg_catalog.pg_namespace n2
1967           ON cl.relnamespace = n2.oid
1968        -- WHERE n2.nspname = 'public'
1969        -- AND cl.relname = 'test'
1970        -- AND a.attname = 'id'
1971  WHERE n2.nspname = 's0' AND cl.relname IS NULL
1972        ORDER BY starelid, staattnum)
1973 TO STDOUT
1974 (FORMAT 'binary');
1975 \o
1976 COMMIT;
1977 COPY dbms_stats.work FROM '@abs_srcdir@/export_stats.dmp' (FORMAT 'binary');
1978 SELECT * FROM work_v;
1979  nspname | relname | relpages | reltuples | relallvisible | curpages | attname | nspname_of_typename | typname | atttypmod | stainherit | stanullfrac | stawidth | stadistinct | stakind1 | stakind2 | stakind3 | stakind4 | stakind5 | staop1 | staop2 | staop3 | staop4 | staop5 | stanumbers1 | stanumbers2 | stanumbers3 | stanumbers4 | stanumbers5 | stavalues1 | stavalues2 | stavalues3 | stavalues4 | stavalues5 
1980 ---------+---------+----------+-----------+---------------+----------+---------+---------------------+---------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+-------------+-------------+-------------+-------------+-------------+------------+------------+------------+------------+------------
1981 (0 rows)
1982
1983 \! rm export_effective_stats.sql.sample_test
1984 TRUNCATE dbms_stats.work;
1985 /*
1986  * Stab function dbms_stats.import
1987  */
1988 ALTER FUNCTION dbms_stats.import(
1989     nspname text,
1990     relid regclass,
1991     attname text,
1992     src text
1993 ) RENAME TO truth_import;
1994 CREATE FUNCTION dbms_stats.import(
1995     nspname text,
1996     relid regclass,
1997     attname text,
1998     src text
1999 ) RETURNS void AS
2000 $$
2001 BEGIN
2002     RAISE NOTICE 'arguments are "%", "%", "%", "%"', $1, $2, $3, $4;
2003     RETURN;
2004 END
2005 $$
2006 LANGUAGE plpgsql;
2007 /*
2008  * No.17-1 dbms_stats.import_database_stats(src)
2009  */
2010 -- No.17-1-1
2011 SELECT dbms_stats.import_database_stats('@abs_srcdir@/export_stats.dmp');
2012 NOTICE:  arguments are "<NULL>", "<NULL>", "<NULL>", "@abs_srcdir@/export_stats.dmp"
2013  import_database_stats 
2014 -----------------------
2015  
2016 (1 row)
2017
2018 /*
2019  * No.17-2 dbms_stats.import_schema_stats(schemaname, src)
2020  */
2021 -- No.17-2-1
2022 SELECT dbms_stats.import_schema_stats('s0', '@abs_srcdir@/export_stats.dmp');
2023 NOTICE:  arguments are "s0", "<NULL>", "<NULL>", "@abs_srcdir@/export_stats.dmp"
2024  import_schema_stats 
2025 ---------------------
2026  
2027 (1 row)
2028
2029 /*
2030  * No.17-3 dbms_stats.import_table_stats(relid, src)
2031  */
2032 -- No.17-3-1
2033 SELECT dbms_stats.import_table_stats('s0.st0', '@abs_srcdir@/export_stats.dmp');
2034 NOTICE:  arguments are "<NULL>", "s0.st0", "<NULL>", "@abs_srcdir@/export_stats.dmp"
2035  import_table_stats 
2036 --------------------
2037  
2038 (1 row)
2039
2040 /*
2041  * No.17-4 dbms_stats.import_table_stats(schemaname, tablename, src)
2042  */
2043 -- No.17-4-1
2044 SELECT dbms_stats.import_table_stats('s0', 'st0', '@abs_srcdir@/export_stats.dmp');
2045 NOTICE:  arguments are "<NULL>", "s0.st0", "<NULL>", "@abs_srcdir@/export_stats.dmp"
2046  import_table_stats 
2047 --------------------
2048  
2049 (1 row)
2050
2051 /*
2052  * No.17-5 dbms_stats.import_column_stats (relid, attname, src)
2053  */
2054 -- No.17-5-1
2055 SELECT dbms_stats.import_column_stats('s0.st0', 'id', '@abs_srcdir@/export_stats.dmp');
2056 NOTICE:  arguments are "<NULL>", "s0.st0", "id", "@abs_srcdir@/export_stats.dmp"
2057  import_column_stats 
2058 ---------------------
2059  
2060 (1 row)
2061
2062 /*
2063  * No.17-6 dbms_stats.import_column_stats (schemaname, tablename, attname, src)
2064  */
2065 -- No.17-6-1
2066 SELECT dbms_stats.import_column_stats('s0', 'st0', 'id','@abs_srcdir@/export_stats.dmp');
2067 NOTICE:  arguments are "<NULL>", "s0.st0", "id", "@abs_srcdir@/export_stats.dmp"
2068  import_column_stats 
2069 ---------------------
2070  
2071 (1 row)
2072
2073 /*
2074  * Delete stab function dbms_stats.import
2075  */
2076 DROP FUNCTION dbms_stats.import(
2077     nspname text,
2078     relid regclass,
2079     attname text,
2080     src text
2081 );
2082 ALTER FUNCTION dbms_stats.truth_import(
2083     nspname text,
2084     relid regclass,
2085     attname text,
2086     src text
2087 ) RENAME TO import;