首页 > 代码库 > About stats collected
About stats collected
pg_class.relpages pg_class.reltuples仅仅是近似值,和实际数据会有点误差;
新建空表。首次insert对自己主动收集和更新统计信息,影响的表pg_class\pg_stats。
对于insert操作:
analyze会更新表pg_class\pg_stats,而vacuum或者acuum full仅仅会更新pg_class。并不会更新不论什么统计信息pg_stats;
对于update\delete操作:
analyze会更新表pg_class\pg_stats,而vacuum或者acuum full仅仅会更新pg_class,并不会更新不论什么统计信息pg_stats;
可是vacuum full对于索引对象的pg_class.relpages貌似存在bug。仅仅有再次analyze或者vacuum才会正确更新pg_class;
gp_autostats_mode能够配置參数有:
NONE
ON_NO_STATS
ON_CHANGE
默认是ON_NO_STATS
gp_autostats_on_change_threshold參数配置阀值。与gp_autostats_mode配合使用,该值为临界值下限,比方80000。那么在超过80000也即等于80001的时候才会生效。
具体測试例如以下: [gpadmin@wx60 ~]$ psql gtlions psql (8.2.15) Type "help" for help. gtlions=# \timing on Timing is on. gtlions=# select version(); version ------------------------------------------------------------------------------------------------------------------------------------------------------ PostgreSQL 8.2.15 (Greenplum Database 4.2.7.2 build 1) on x86_64-unknown-linux-gnu, compiled by GCC gcc (GCC) 4.4.2 compiled on Feb 25 2014 18:05:04 (1 row) Time: 2.020 ms gtlions=# \pset x Expanded display is on. gtlions=# select * from pg_settings where name ~ 'gp_autostats'; -[ RECORD 1 ]--------------------------------------------------------------------------------------------------------------------------------- name | gp_autostats_mode setting | ON_NO_STATS unit | category | Developer Options short_desc | Sets the autostats mode. extra_desc | Valid values are NONE, ON_CHANGE, ON_NO_STATS. ON_CHANGE requires setting gp_autostats_on_change_threshold. context | user vartype | string source | configuration file min_val | max_val | -[ RECORD 2 ]--------------------------------------------------------------------------------------------------------------------------------- name | gp_autostats_on_change_threshold setting | 2147483647 unit | category | Developer Options short_desc | Threshold for number of tuples added to table by CTAS or Insert-to to trigger autostats in on_change mode. See gp_autostats_mode. extra_desc | context | user vartype | integer source | configuration file min_val | 0 max_val | 2147483647 Time: 4.464 ms gtlions=# \q [gpadmin@wx60 ~]$ gpconfig -c gp_autostats_on_change_threshold -v 80000 20141017:16:45:27:008114 gpconfig:wx60:gpadmin-[INFO]:-completed successfully [gpadmin@wx60 ~]$ gpstop -u 20141017:16:45:32:008229 gpstop:wx60:gpadmin-[INFO]:-Starting gpstop with args: -u 20141017:16:45:32:008229 gpstop:wx60:gpadmin-[INFO]:-Gathering information and validating the environment... 20141017:16:45:32:008229 gpstop:wx60:gpadmin-[INFO]:-Obtaining Greenplum Master catalog information 20141017:16:45:32:008229 gpstop:wx60:gpadmin-[INFO]:-Obtaining Segment details from master... 20141017:16:45:33:008229 gpstop:wx60:gpadmin-[INFO]:-Greenplum Version: 'postgres (Greenplum Database) 4.2.7.2 build 1' 20141017:16:45:33:008229 gpstop:wx60:gpadmin-[INFO]:-Signalling all postmaster processes to reload . [gpadmin@wx60 ~]$ psql gtlions psql (8.2.15) Type "help" for help. gtlions=# \pset x Expanded display is on. gtlions=# select * from pg_settings where name ~ 'gp_autostats'; -[ RECORD 1 ]--------------------------------------------------------------------------------------------------------------------------------- name | gp_autostats_mode setting | ON_NO_STATS unit | category | Developer Options short_desc | Sets the autostats mode. extra_desc | Valid values are NONE, ON_CHANGE, ON_NO_STATS. ON_CHANGE requires setting gp_autostats_on_change_threshold. context | user vartype | string source | configuration file min_val | max_val | -[ RECORD 2 ]--------------------------------------------------------------------------------------------------------------------------------- name | gp_autostats_on_change_threshold setting | 80000 unit | category | Developer Options short_desc | Threshold for number of tuples added to table by CTAS or Insert-to to trigger autostats in on_change mode. See gp_autostats_mode. extra_desc | context | user vartype | integer source | configuration file min_val | 0 max_val | 2147483647 gtlions=# drop table if exists test; DROP TABLE gtlions=# create table test ( id int, name varchar(200),age int); NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'id' as the Greenplum Database data distribution key for this table. HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew. CREATE TABLE gtlions=# select relname,relfilenode,relpages,reltuples,relhasindex,relnatts from pg_class where relname in ('test') order by relname; -[ RECORD 1 ]------ relname | test relfilenode | 35843 relpages | 0 reltuples | 0 relhasindex | f relnatts | 3 gtlions=# \pset x Expanded display is off. gtlions=# select relname,relfilenode,relpages,reltuples,relhasindex,relnatts from pg_class where relname in ('test') order by relname; relname | relfilenode | relpages | reltuples | relhasindex | relnatts ---------+-------------+----------+-----------+-------------+---------- test | 35843 | 0 | 0 | f | 3 (1 row) gtlions=# select * from pg_stats where tablename='test'; schemaname | tablename | attname | null_frac | avg_width | n_distinct | most_common_vals | most_common_freqs | histogram_bounds | correlation ------------+-----------+---------+-----------+-----------+------------+------------------+-------------------+------------------+------------- (0 rows) gtlions=# select * from gp_toolkit.gp_stats_missing gtlions=# select * from gp_toolkit.gp_stats_missing where smitable='test'; smischema | smitable | smisize | smicols | smirecs -----------+----------+---------+---------+--------- public | test | f | 3 | 0 (1 row) gtlions=# insert into test select generate_series(1,80000),generate_series(1,80000)||'-aaa-bbb',round(random()::numeric,2)*100 limit 20000; INSERT 0 20000 gtlions=# select relname,relfilenode,relpages,reltuples,relhasindex,relnatts from pg_class where relname in ('test') order by relname; relname | relfilenode | relpages | reltuples | relhasindex | relnatts ---------+-------------+----------+-----------+-------------+---------- test | 35843 | 32 | 20000 | f | 3 (1 row) gtlions=# select * from pg_stats where tablename='test'; schemaname | tablename | attname | null_frac | avg_width | n_distinct | most_common_vals | most_common_freqs | histogram_bounds | correlation ------------+-----------+---------+-----------+-----------+------------+------------------+-------------------+-------------------------------------------------------- --------------------------------------------------------------------------------------+------------- public | test | id | 0 | 4 | -1 | | | {1,801,1601,2401,3201,4001,4801,5601,6401,7201,8001,880 1,9601,10401,11201,12001,12801,13601,14401,15201,16001,16801,17601,18401,19201,20000} | public | test | name | 0 | 13 | -1 | | | | public | test | age | 0 | 4 | 1 | {39} | {1} | {39} | (3 rows) gtlions=# select * from gp_toolkit.gp_stats_missing where smitable='test'; smischema | smitable | smisize | smicols | smirecs -----------+----------+---------+---------+--------- (0 rows) gtlions=# \q [gpadmin@wx60 ~]$ gpconfig -c gp_autostats_mode -v NONE 20141017:16:50:17:008707 gpconfig:wx60:gpadmin-[INFO]:-completed successfully [gpadmin@wx60 ~]$ gpstop -u 20141017:16:50:20:008822 gpstop:wx60:gpadmin-[INFO]:-Starting gpstop with args: -u 20141017:16:50:20:008822 gpstop:wx60:gpadmin-[INFO]:-Gathering information and validating the environment... 20141017:16:50:20:008822 gpstop:wx60:gpadmin-[INFO]:-Obtaining Greenplum Master catalog information 20141017:16:50:20:008822 gpstop:wx60:gpadmin-[INFO]:-Obtaining Segment details from master... 20141017:16:50:20:008822 gpstop:wx60:gpadmin-[INFO]:-Greenplum Version: 'postgres (Greenplum Database) 4.2.7.2 build 1' 20141017:16:50:20:008822 gpstop:wx60:gpadmin-[INFO]:-Signalling all postmaster processes to reload . [gpadmin@wx60 ~]$ psql gtlions psql (8.2.15) Type "help" for help. gtlions=# \pset x Expanded display is on. gtlions=# select * from pg_settings where name ~ 'gp_autostats'; -[ RECORD 1 ]--------------------------------------------------------------------------------------------------------------------------------- name | gp_autostats_mode setting | NONE unit | category | Developer Options short_desc | Sets the autostats mode. extra_desc | Valid values are NONE, ON_CHANGE, ON_NO_STATS. ON_CHANGE requires setting gp_autostats_on_change_threshold. context | user vartype | string source | configuration file min_val | max_val | -[ RECORD 2 ]--------------------------------------------------------------------------------------------------------------------------------- name | gp_autostats_on_change_threshold setting | 80000 unit | category | Developer Options short_desc | Threshold for number of tuples added to table by CTAS or Insert-to to trigger autostats in on_change mode. See gp_autostats_mode. extra_desc | context | user vartype | integer source | configuration file min_val | 0 max_val | 2147483647 gtlions=# drop table test; DROP TABLE gtlions=# \pset x Expanded display is off. gtlions=# create table test ( id int, name varchar(200),age int); NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'id' as the Greenplum Database data distribution key for this table. HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew. CREATE TABLE gtlions=# insert into test select generate_series(1,80000),generate_series(1,80000)||'-aaa-bbb',round(random()::numeric,2)*100 limit 20000; INSERT 0 20000 gtlions=# select relname,relfilenode,relpages,reltuples,relhasindex,relnatts from pg_class where relname in ('test') order by relname; relname | relfilenode | relpages | reltuples | relhasindex | relnatts ---------+-------------+----------+-----------+-------------+---------- test | 35866 | 0 | 0 | f | 3 (1 row) gtlions=# select * from pg_stats where tablename='test'; schemaname | tablename | attname | null_frac | avg_width | n_distinct | most_common_vals | most_common_freqs | histogram_bounds | correlation ------------+-----------+---------+-----------+-----------+------------+------------------+-------------------+------------------+------------- (0 rows) gtlions=# select * from gp_toolkit.gp_stats_missing where smitable='test'; smischema | smitable | smisize | smicols | smirecs -----------+----------+---------+---------+--------- public | test | f | 3 | 0 (1 row) gtlions=# analyze test; ANALYZE gtlions=# select relname,relfilenode,relpages,reltuples,relhasindex,relnatts from pg_class where relname in ('test') order by relname; relname | relfilenode | relpages | reltuples | relhasindex | relnatts ---------+-------------+----------+-----------+-------------+---------- test | 35866 | 32 | 20000 | f | 3 (1 row) gtlions=# select * from pg_stats where tablename='test'; schemaname | tablename | attname | null_frac | avg_width | n_distinct | most_common_vals | most_common_freqs | histogram_bounds | correlation ------------+-----------+---------+-----------+-----------+------------+------------------+-------------------+-------------------------------------------------------- --------------------------------------------------------------------------------------+------------- public | test | id | 0 | 4 | -1 | | | {1,801,1601,2401,3201,4001,4801,5601,6401,7201,8001,880 1,9601,10401,11201,12001,12801,13601,14401,15201,16001,16801,17601,18401,19201,20000} | public | test | name | 0 | 13 | -1 | | | | public | test | age | 0 | 4 | 1 | {32} | {1} | {32} | (3 rows) gtlions=# select * from gp_toolkit.gp_stats_missing where smitable='test'; smischema | smitable | smisize | smicols | smirecs -----------+----------+---------+---------+--------- (0 rows) gtlions=# \q [gpadmin@wx60 ~]$ gpconfig -c gp_autostats_mode -v ON_CHANGE 20141017:16:52:15:009211 gpconfig:wx60:gpadmin-[INFO]:-completed successfully [gpadmin@wx60 ~]$ gpstop -u 20141017:16:52:18:009326 gpstop:wx60:gpadmin-[INFO]:-Starting gpstop with args: -u 20141017:16:52:18:009326 gpstop:wx60:gpadmin-[INFO]:-Gathering information and validating the environment... 20141017:16:52:18:009326 gpstop:wx60:gpadmin-[INFO]:-Obtaining Greenplum Master catalog information 20141017:16:52:18:009326 gpstop:wx60:gpadmin-[INFO]:-Obtaining Segment details from master... 20141017:16:52:18:009326 gpstop:wx60:gpadmin-[INFO]:-Greenplum Version: 'postgres (Greenplum Database) 4.2.7.2 build 1' 20141017:16:52:18:009326 gpstop:wx60:gpadmin-[INFO]:-Signalling all postmaster processes to reload . [gpadmin@wx60 ~]$ psql gtlions psql (8.2.15) Type "help" for help. gtlions=# \pset x Expanded display is on. gtlions=# select * from pg_settings where name ~ 'gp_autostats'; -[ RECORD 1 ]--------------------------------------------------------------------------------------------------------------------------------- name | gp_autostats_mode setting | ON_CHANGE unit | category | Developer Options short_desc | Sets the autostats mode. extra_desc | Valid values are NONE, ON_CHANGE, ON_NO_STATS. ON_CHANGE requires setting gp_autostats_on_change_threshold. context | user vartype | string source | configuration file min_val | max_val | -[ RECORD 2 ]--------------------------------------------------------------------------------------------------------------------------------- name | gp_autostats_on_change_threshold setting | 80000 unit | category | Developer Options short_desc | Threshold for number of tuples added to table by CTAS or Insert-to to trigger autostats in on_change mode. See gp_autostats_mode. extra_desc | context | user vartype | integer source | configuration file min_val | 0 max_val | 2147483647 gtlions=# \pset x Expanded display is off. gtlions=# drop table test; DROP TABLE gtlions=# create table test ( id int, name varchar(200),age int); NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'id' as the Greenplum Database data distribution key for this table. HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew. CREATE TABLE gtlions=# insert into test select generate_series(1,80000),generate_series(1,80000)||'-aaa-bbb',round(random()::numeric,2)*100 limit 20000; INSERT 0 20000 gtlions=# select relname,relfilenode,relpages,reltuples,relhasindex,relnatts from pg_class where relname in ('test') order by relname; relname | relfilenode | relpages | reltuples | relhasindex | relnatts ---------+-------------+----------+-----------+-------------+---------- test | 35889 | 0 | 0 | f | 3 (1 row) gtlions=# select * from pg_stats where tablename='test'; schemaname | tablename | attname | null_frac | avg_width | n_distinct | most_common_vals | most_common_freqs | histogram_bounds | correlation ------------+-----------+---------+-----------+-----------+------------+------------------+-------------------+------------------+------------- (0 rows) gtlions=# select * from gp_toolkit.gp_stats_missing where smitable='test'; smischema | smitable | smisize | smicols | smirecs -----------+----------+---------+---------+--------- public | test | f | 3 | 0 (1 row) gtlions=# insert into test select generate_series(1,80000),generate_series(1,80000)||'-aaa-bbb',round(random()::numeric,2)*100 limit 20000; INSERT 0 20000 gtlions=# select * from pg_stats where tablename='test'; schemaname | tablename | attname | null_frac | avg_width | n_distinct | most_common_vals | most_common_freqs | histogram_bounds | correlation ------------+-----------+---------+-----------+-----------+------------+------------------+-------------------+------------------+------------- (0 rows) gtlions=# insert into test select generate_series(1,80000),generate_series(1,80000)||'-aaa-bbb',round(random()::numeric,2)*100 limit 20000; INSERT 0 20000 gtlions=# select * from pg_stats where tablename='test'; schemaname | tablename | attname | null_frac | avg_width | n_distinct | most_common_vals | most_common_freqs | histogram_bounds | correlation ------------+-----------+---------+-----------+-----------+------------+------------------+-------------------+------------------+------------- (0 rows) gtlions=# select count(*) from test; count ------- 60000 (1 row) gtlions=# insert into test select generate_series(1,80000),generate_series(1,80000)||'-aaa-bbb',round(random()::numeric,2)*100 limit 19999; INSERT 0 19999 gtlions=# select count(*) from test; count ------- 79999 (1 row) gtlions=# select count(*) from test; count ------- 79999 (1 row) gtlions=# select * from pg_stats where tablename='test'; schemaname | tablename | attname | null_frac | avg_width | n_distinct | most_common_vals | most_common_freqs | histogram_bounds | correlation ------------+-----------+---------+-----------+-----------+------------+------------------+-------------------+------------------+------------- (0 rows) gtlions=# insert into test select generate_series(1,80000),generate_series(1,80000)||'-aaa-bbb',round(random()::numeric,2)*100 limit 1; INSERT 0 1 gtlions=# select count(*) from test; count ------- 80000 (1 row) gtlions=# select * from pg_stats where tablename='test'; schemaname | tablename | attname | null_frac | avg_width | n_distinct | most_common_vals | most_common_freqs | histogram_bounds | correlation ------------+-----------+---------+-----------+-----------+------------+------------------+-------------------+------------------+------------- (0 rows) gtlions=# insert into test select generate_series(1,80000),generate_series(1,80000)||'-aaa-bbb',round(random()::numeric,2)*100 limit 1; INSERT 0 1 gtlions=# select count(*) from test; count ------- 80001 (1 row) gtlions=# select * from pg_stats where tablename='test'; schemaname | tablename | attname | null_frac | avg_width | n_distinct | most_common_vals | most_common_freqs | histogram_bounds | correlation ------------+-----------+---------+-----------+-----------+------------+------------------+-------------------+------------------+------------- (0 rows) gtlions=# select * from pg_stats where tablename='test'; schemaname | tablename | attname | null_frac | avg_width | n_distinct | most_common_vals | most_common_freqs | histogram_bounds | correlation ------------+-----------+---------+-----------+-----------+------------+------------------+-------------------+------------------+------------- (0 rows) gtlions=# select relname,relfilenode,relpages,reltuples,relhasindex,relnatts from pg_class where relname in ('test') order by relname; relname | relfilenode | relpages | reltuples | relhasindex | relnatts ---------+-------------+----------+-----------+-------------+---------- test | 35889 | 0 | 0 | f | 3 (1 row) gtlions=# insert into test select generate_series(1,80000),generate_series(1,80000)||'-aaa-bbb',round(random()::numeric,2)*100 limit 10000; INSERT 0 10000 gtlions=# select count(*) from test; count ------- 90001 (1 row) gtlions=# select relname,relfilenode,relpages,reltuples,relhasindex,relnatts from pg_class where relname in ('test') order by relname; relname | relfilenode | relpages | reltuples | relhasindex | relnatts ---------+-------------+----------+-----------+-------------+---------- test | 35889 | 0 | 0 | f | 3 (1 row) gtlions=# select * from pg_stats where tablename='test'; schemaname | tablename | attname | null_frac | avg_width | n_distinct | most_common_vals | most_common_freqs | histogram_bounds | correlation ------------+-----------+---------+-----------+-----------+------------+------------------+-------------------+------------------+------------- (0 rows) gtlions=# insert into test select generate_series(1,80000),generate_series(1,80000)||'-aaa-bbb',round(random()::numeric,2)*100 limit 10000; INSERT 0 10000 gtlions=# insert into test select generate_series(1,80000),generate_series(1,80000)||'-aaa-bbb',round(random()::numeric,2)*100 limit 10000; INSERT 0 10000 gtlions=# insert into test select generate_series(1,80000),generate_series(1,80000)||'-aaa-bbb',round(random()::numeric,2)*100 limit 10000; INSERT 0 10000 gtlions=# select relname,relfilenode,relpages,reltuples,relhasindex,relnatts from pg_class where relname in ('test') order by relname; relname | relfilenode | relpages | reltuples | relhasindex | relnatts ---------+-------------+----------+-----------+-------------+---------- test | 35889 | 0 | 0 | f | 3 (1 row) gtlions=# select * from pg_stats where tablename='test'; schemaname | tablename | attname | null_frac | avg_width | n_distinct | most_common_vals | most_common_freqs | histogram_bounds | correlation ------------+-----------+---------+-----------+-----------+------------+------------------+-------------------+------------------+------------- (0 rows) gtlions=# insert into test select generate_series(1,80000),generate_series(1,80000)||'-aaa-bbb',round(random()::numeric,2)*100 limit 80000; INSERT 0 80000 gtlions=# select relname,relfilenode,relpages,reltuples,relhasindex,relnatts from pg_class where relname in ('test') order by relname; relname | relfilenode | relpages | reltuples | relhasindex | relnatts ---------+-------------+----------+-----------+-------------+---------- test | 35889 | 0 | 0 | f | 3 (1 row) gtlions=# select * from pg_stats where tablename='test'; schemaname | tablename | attname | null_frac | avg_width | n_distinct | most_common_vals | most_common_freqs | histogram_bounds | correlation ------------+-----------+---------+-----------+-----------+------------+------------------+-------------------+------------------+------------- (0 rows) gtlions=# insert into test select generate_series(1,80000),generate_series(1,80000)||'-aaa-bbb',round(random()::numeric,2)*100 limit 80000; INSERT 0 80000 gtlions=# select relname,relfilenode,relpages,reltuples,relhasindex,relnatts from pg_class where relname in ('test') order by relname; relname | relfilenode | relpages | reltuples | relhasindex | relnatts ---------+-------------+----------+-----------+-------------+---------- test | 35889 | 0 | 0 | f | 3 (1 row) gtlions=# select * from pg_stats where tablename='test'; schemaname | tablename | attname | null_frac | avg_width | n_distinct | most_common_vals | most_common_freqs | histogram_bounds | correlation ------------+-----------+---------+-----------+-----------+------------+------------------+-------------------+------------------+------------- (0 rows) gtlions=# insert into test select generate_series(1,90000),generate_series(1,90000)||'-aaa-bbb',round(random()::numeric,2)*100 limit 80001; INSERT 0 80001 gtlions=# select relname,relfilenode,relpages,reltuples,relhasindex,relnatts from pg_class where relname in ('test') order by relname; relname | relfilenode | relpages | reltuples | relhasindex | relnatts ---------+-------------+----------+-----------+-------------+---------- test | 35889 | 574 | 361046 | f | 3 (1 row) gtlions=# select * from pg_stats where tablename='test'; schemaname | tablename | attname | null_frac | avg_width | n_distinct | most_common_vals | most_common_freqs | histogram_bounds | correla tion ------------+-----------+---------+-----------+-----------+------------+----------------------------------------------------------------------------------------------- ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- --------------------------------------------------------------------+-------------------------------------------------------------------------------------------------- ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- ---+----------------------------------------------------------------------------------------------------------------------------------------------------------+-------- ----- public | test | id | 0 | 4 | -0.174002 | {1241,7638,3257,2327,1485,9298,2465,6481,6316,2423,1618,1694,5551,3915,6216,15550,11567,3513,3 088,18221,1274,7119,1266,5539,5937} | {0.00020724,0.0001727,0.0001727,0.0001727,0.0001727,0.0001727,0.0001727,0.0001727,0.0001727,0.000 1727,0.0001727,0.00013816,0.00013816,0.00013816,0.00013816,0.00013816,0.00013816,0.00013816,0.00013816,0.00013816,0.00013816,0.00013816,0.00013816,0.00013816,0.0001381 6} | {2,1361,2586,3868,5172,6432,7736,9052,10533,12609,14761,16810,18829,22174,27068,31789,36502,41340,46046,50856,55455,60203,65163,69993,74722,79997,79998} | public | test | name | 0 | 13 | -0.174002 | {1241-aaa-bbb,1485-aaa-bbb,6316-aaa-bbb,9298-aaa-bbb,1618-aaa-bbb,7638-aaa-bbb,2327-aaa-bbb,64 81-aaa-bbb,3257-aaa-bbb,2465-aaa-bbb,2423-aaa-bbb,1266-aaa-bbb,8043-aaa-bbb,4306-aaa-bbb,7255-aaa-bbb,19759-aaa-bbb,6083-aaa-bbb,4287-aaa-bbb,14424-aaa-bbb,4623-aaa-bb b,8661-aaa-bbb,4980-aaa-bbb,5161-aaa-bbb,8999-aaa-bbb,8694-aaa-bbb} | {0.00020724,0.0001727,0.0001727,0.0001727,0.0001727,0.0001727,0.0001727,0.0001727,0.0001727,0.000 1727,0.0001727,0.00013816,0.00013816,0.00013816,0.00013816,0.00013816,0.00013816,0.00013816,0.00013816,0.00013816,0.00013816,0.00013816,0.00013816,0.00013816,0.0001381 6} | | public | test | age | 0 | 4 | 11 | {19,10,74,32,68,35,75,5,65,93,46} | {0.224026,0.221021,0.217878,0.0573708,0.0556784,0.0546422,0.0538823,0.0300497,0.0290826,0.0285991 ,0.0277701} | {5,10,19,32,35,46,65,68,74,75,93} | (3 rows) gtlions=# truncate tabel test; ERROR: syntax error at or near "test" LINE 1: truncate tabel test; ^ gtlions=# truncate table test; TRUNCATE TABLE gtlions=# select relname,relfilenode,relpages,reltuples,relhasindex,relnatts from pg_class where relname in ('test') order by relname; relname | relfilenode | relpages | reltuples | relhasindex | relnatts ---------+-------------+----------+-----------+-------------+---------- test | 35936 | 0 | 0 | f | 3 (1 row) gtlions=# insert into test select generate_series(1,90000),generate_series(1,90000)||'-aaa-bbb',round(random()::numeric,2)*100 limit 90000; INSERT 0 90000 gtlions=# select relname,relfilenode,relpages,reltuples,relhasindex,relnatts from pg_class where relname in ('test') order by relname; relname | relfilenode | relpages | reltuples | relhasindex | relnatts ---------+-------------+----------+-----------+-------------+---------- test | 35936 | 144 | 90576 | f | 3 (1 row) gtlions=# update test set name='a' where id<=79999; UPDATE 79999 gtlions=# select relname,relfilenode,relpages,reltuples,relhasindex,relnatts from pg_class where relname in ('test') order by relname; relname | relfilenode | relpages | reltuples | relhasindex | relnatts ---------+-------------+----------+-----------+-------------+---------- test | 35936 | 144 | 90576 | f | 3 (1 row) gtlions=# update test set name='a' where id<=79999; UPDATE 79999 gtlions=# select relname,relfilenode,relpages,reltuples,relhasindex,relnatts from pg_class where relname in ('test') order by relname; relname | relfilenode | relpages | reltuples | relhasindex | relnatts ---------+-------------+----------+-----------+-------------+---------- test | 35936 | 144 | 90576 | f | 3 (1 row) gtlions=# update test set name='a' where id<=80000; UPDATE 80000 gtlions=# select relname,relfilenode,relpages,reltuples,relhasindex,relnatts from pg_class where relname in ('test') order by relname; relname | relfilenode | relpages | reltuples | relhasindex | relnatts ---------+-------------+----------+-----------+-------------+---------- test | 35936 | 144 | 90576 | f | 3 (1 row) gtlions=# select relname,relfilenode,relpages,reltuples,relhasindex,relnatts from pg_class where relname in ('test') order by relname; relname | relfilenode | relpages | reltuples | relhasindex | relnatts ---------+-------------+----------+-----------+-------------+---------- test | 35936 | 144 | 90576 | f | 3 (1 row) gtlions=# update test set name='a' where id<=80001; UPDATE 80001 gtlions=# select relname,relfilenode,relpages,reltuples,relhasindex,relnatts from pg_class where relname in ('test') order by relname; relname | relfilenode | relpages | reltuples | relhasindex | relnatts ---------+-------------+----------+-----------+-------------+---------- test | 35936 | 574 | 101174 | f | 3 (1 row) gtlions=# truncate table test; TRUNCATE TABLE gtlions=# select relname,relfilenode,relpages,reltuples,relhasindex,relnatts from pg_class where relname in ('test') order by relname; relname | relfilenode | relpages | reltuples | relhasindex | relnatts ---------+-------------+----------+-----------+-------------+---------- test | 35995 | 0 | 0 | f | 3 (1 row) gtlions=# insert into test select generate_series(1,90000),generate_series(1,90000)||'-aaa-bbb',round(random()::numeric,2)*100 limit 90000; INSERT 0 90000 gtlions=# select relname,relfilenode,relpages,reltuples,relhasindex,relnatts from pg_class where relname in ('test') order by relname; relname | relfilenode | relpages | reltuples | relhasindex | relnatts ---------+-------------+----------+-----------+-------------+---------- test | 35995 | 144 | 90576 | f | 3 (1 row) gtlions=# update test set name='a' where id<80000; UPDATE 79999 gtlions=# select relname,relfilenode,relpages,reltuples,relhasindex,relnatts from pg_class where relname in ('test') order by relname; relname | relfilenode | relpages | reltuples | relhasindex | relnatts ---------+-------------+----------+-----------+-------------+---------- test | 35995 | 144 | 90576 | f | 3 (1 row) gtlions=# update test set name='a' where id<80001; UPDATE 80000 gtlions=# select relname,relfilenode,relpages,reltuples,relhasindex,relnatts from pg_class where relname in ('test') order by relname; relname | relfilenode | relpages | reltuples | relhasindex | relnatts ---------+-------------+----------+-----------+-------------+---------- test | 35995 | 144 | 90576 | f | 3 (1 row) gtlions=# update test set name='a' where id<80002; UPDATE 80001 gtlions=# select relname,relfilenode,relpages,reltuples,relhasindex,relnatts from pg_class where relname in ('test') order by relname; relname | relfilenode | relpages | reltuples | relhasindex | relnatts ---------+-------------+----------+-----------+-------------+---------- test | 35995 | 466 | 66052 | f | 3 (1 row)
-EOF-
About stats collected
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。