PG重建索引
2017-10-20 16:47
197 查看
postgres=# select version();
version
------------------------------------------------------------------------------------------------------------------------
PostgreSQL 8.1.22 on x86_64-unknown-linux-gnu, compiled by GCC gcc (SUSE Linux) 4.3.4 [gcc-4_3-branch revision 152973]
(1 row)
注意:reindex 会造成全表锁。
postgres=# reindex index t_idx; -->重建单个索引
REINDEX
postgres=# reindex table test; -->重建和表test有关的索引
REINDEX
postgres@linux-o8rc:~> reindexdb postgres -->重建postgres数据库下所有的索引
NOTICE: table "pg_class" was reindexed
NOTICE: table "pg_class" was reindexed
NOTICE: table "sql_features" was reindexed
NOTICE: table "sql_features" was reindexed
NOTICE: table "sql_implementation_info" was reindexed
NOTICE: table "sql_implementation_info" was reindexed
NOTICE: table "sql_languages" was reindexed
NOTICE: table "sql_languages" was reindexed
NOTICE: table "sql_packages" was reindexed
NOTICE: table "sql_packages" was reindexed
NOTICE: table "sql_sizing" was reindexed
NOTICE: table "sql_sizing" was reindexed
NOTICE: table "sql_sizing_profiles" was reindexed
NOTICE: table "sql_sizing_profiles" was reindexed
NOTICE: table "pg_statistic" was reindexed
NOTICE: table "pg_statistic" was reindexed
NOTICE: table "pg_type" was reindexed
NOTICE: table "pg_type" was reindexed
NOTICE: table "pg_attribute" was reindexed
NOTICE: table "pg_attribute" was reindexed
NOTICE: table "pg_autovacuum" was reindexed
NOTICE: table "pg_autovacuum" was reindexed
NOTICE: table "pg_inherits" was reindexed
NOTICE: table "pg_inherits" was reindexed
NOTICE: table "pg_index" was reindexed
NOTICE: table "pg_index" was reindexed
NOTICE: table "pg_operator" was reindexed
NOTICE: table "pg_operator" was reindexed
NOTICE: table "pg_opclass" was reindexed
NOTICE: table "pg_opclass" was reindexed
NOTICE: table "pg_am" was reindexed
NOTICE: table "pg_am" was reindexed
NOTICE: table "pg_amop" was reindexed
NOTICE: table "pg_amop" was reindexed
NOTICE: table "pg_amproc" was reindexed
NOTICE: table "pg_amproc" was reindexed
NOTICE: table "pg_language" was reindexed
NOTICE: table "pg_language" was reindexed
NOTICE: table "pg_largeobject" was reindexed
NOTICE: table "pg_largeobject" was reindexed
NOTICE: table "pg_aggregate" was reindexed
NOTICE: table "pg_aggregate" was reindexed
NOTICE: table "pg_trigger" was reindexed
NOTICE: table "pg_trigger" was reindexed
NOTICE: table "pg_cast" was reindexed
NOTICE: table "pg_cast" was reindexed
NOTICE: table "pg_namespace" was reindexed
NOTICE: table "pg_namespace" was reindexed
NOTICE: table "pg_conversion" was reindexed
NOTICE: table "pg_conversion" was reindexed
NOTICE: table "pg_depend" was reindexed
NOTICE: table "pg_depend" was reindexed
NOTICE: table "tbl_kenyon" was reindexed
NOTICE: table "tbl_kenyon" was reindexed
NOTICE: table "test" was reindexed
NOTICE: table "test" was reindexed
NOTICE: table "pg_attrdef" was reindexed
NOTICE: table "pg_attrdef" was reindexed
NOTICE: table "pg_constraint" was reindexed
NOTICE: table "pg_constraint" was reindexed
NOTICE: table "pg_description" was reindexed
NOTICE: table "pg_description" was reindexed
NOTICE: table "pg_proc" was reindexed
NOTICE: table "pg_proc" was reindexed
NOTICE: table "pg_rewrite" was reindexed
NOTICE: table "pg_rewrite" was reindexed
REINDEX
postgres=# reindex database postgres; -->重建postgres数据库下所有的索引
NOTICE: table "pg_class" was reindexed
NOTICE: table "sql_features" was reindexed
NOTICE: table "sql_implementation_info" was reindexed
NOTICE: table "sql_languages" was reindexed
NOTICE: table "sql_packages" was reindexed
NOTICE: table "sql_sizing" was reindexed
NOTICE: table "sql_sizing_profiles" was reindexed
NOTICE: table "pg_statistic" was reindexed
NOTICE: table "pg_autovacuum" was reindexed
NOTICE: table "pg_inherits" was reindexed
NOTICE: table "pg_operator" was reindexed
NOTICE: table "pg_opclass" was reindexed
NOTICE: table "pg_am" was reindexed
NOTICE: table "pg_amop" was reindexed
NOTICE: table "pg_amproc" was reindexed
NOTICE: table "pg_language" was reindexed
NOTICE: table "pg_largeobject" was reindexed
NOTICE: table "pg_aggregate" was reindexed
NOTICE: table "pg_trigger" was reindexed
NOTICE: table "pg_cast" was reindexed
NOTICE: table "pg_namespace" was reindexed
NOTICE: table "pg_conversion" was reindexed
NOTICE: table "tbl_kenyon" was reindexed
NOTICE: table "test" was reindexed
NOTICE: table "pg_attrdef" was reindexed
NOTICE: table "pg_constraint" was reindexed
NOTICE: table "pg_description" was reindexed
NOTICE: table "pg_proc" was reindexed
NOTICE: table "pg_rewrite" was reindexed
NOTICE: table "pg_type" was reindexed
NOTICE: table "pg_attribute" was reindexed
NOTICE: table "pg_index" was reindexed
NOTICE: table "pg_depend" was reindexed
REINDEX
version
------------------------------------------------------------------------------------------------------------------------
PostgreSQL 8.1.22 on x86_64-unknown-linux-gnu, compiled by GCC gcc (SUSE Linux) 4.3.4 [gcc-4_3-branch revision 152973]
(1 row)
注意:reindex 会造成全表锁。
postgres=# reindex index t_idx; -->重建单个索引
REINDEX
postgres=# reindex table test; -->重建和表test有关的索引
REINDEX
postgres@linux-o8rc:~> reindexdb postgres -->重建postgres数据库下所有的索引
NOTICE: table "pg_class" was reindexed
NOTICE: table "pg_class" was reindexed
NOTICE: table "sql_features" was reindexed
NOTICE: table "sql_features" was reindexed
NOTICE: table "sql_implementation_info" was reindexed
NOTICE: table "sql_implementation_info" was reindexed
NOTICE: table "sql_languages" was reindexed
NOTICE: table "sql_languages" was reindexed
NOTICE: table "sql_packages" was reindexed
NOTICE: table "sql_packages" was reindexed
NOTICE: table "sql_sizing" was reindexed
NOTICE: table "sql_sizing" was reindexed
NOTICE: table "sql_sizing_profiles" was reindexed
NOTICE: table "sql_sizing_profiles" was reindexed
NOTICE: table "pg_statistic" was reindexed
NOTICE: table "pg_statistic" was reindexed
NOTICE: table "pg_type" was reindexed
NOTICE: table "pg_type" was reindexed
NOTICE: table "pg_attribute" was reindexed
NOTICE: table "pg_attribute" was reindexed
NOTICE: table "pg_autovacuum" was reindexed
NOTICE: table "pg_autovacuum" was reindexed
NOTICE: table "pg_inherits" was reindexed
NOTICE: table "pg_inherits" was reindexed
NOTICE: table "pg_index" was reindexed
NOTICE: table "pg_index" was reindexed
NOTICE: table "pg_operator" was reindexed
NOTICE: table "pg_operator" was reindexed
NOTICE: table "pg_opclass" was reindexed
NOTICE: table "pg_opclass" was reindexed
NOTICE: table "pg_am" was reindexed
NOTICE: table "pg_am" was reindexed
NOTICE: table "pg_amop" was reindexed
NOTICE: table "pg_amop" was reindexed
NOTICE: table "pg_amproc" was reindexed
NOTICE: table "pg_amproc" was reindexed
NOTICE: table "pg_language" was reindexed
NOTICE: table "pg_language" was reindexed
NOTICE: table "pg_largeobject" was reindexed
NOTICE: table "pg_largeobject" was reindexed
NOTICE: table "pg_aggregate" was reindexed
NOTICE: table "pg_aggregate" was reindexed
NOTICE: table "pg_trigger" was reindexed
NOTICE: table "pg_trigger" was reindexed
NOTICE: table "pg_cast" was reindexed
NOTICE: table "pg_cast" was reindexed
NOTICE: table "pg_namespace" was reindexed
NOTICE: table "pg_namespace" was reindexed
NOTICE: table "pg_conversion" was reindexed
NOTICE: table "pg_conversion" was reindexed
NOTICE: table "pg_depend" was reindexed
NOTICE: table "pg_depend" was reindexed
NOTICE: table "tbl_kenyon" was reindexed
NOTICE: table "tbl_kenyon" was reindexed
NOTICE: table "test" was reindexed
NOTICE: table "test" was reindexed
NOTICE: table "pg_attrdef" was reindexed
NOTICE: table "pg_attrdef" was reindexed
NOTICE: table "pg_constraint" was reindexed
NOTICE: table "pg_constraint" was reindexed
NOTICE: table "pg_description" was reindexed
NOTICE: table "pg_description" was reindexed
NOTICE: table "pg_proc" was reindexed
NOTICE: table "pg_proc" was reindexed
NOTICE: table "pg_rewrite" was reindexed
NOTICE: table "pg_rewrite" was reindexed
REINDEX
postgres=# reindex database postgres; -->重建postgres数据库下所有的索引
NOTICE: table "pg_class" was reindexed
NOTICE: table "sql_features" was reindexed
NOTICE: table "sql_implementation_info" was reindexed
NOTICE: table "sql_languages" was reindexed
NOTICE: table "sql_packages" was reindexed
NOTICE: table "sql_sizing" was reindexed
NOTICE: table "sql_sizing_profiles" was reindexed
NOTICE: table "pg_statistic" was reindexed
NOTICE: table "pg_autovacuum" was reindexed
NOTICE: table "pg_inherits" was reindexed
NOTICE: table "pg_operator" was reindexed
NOTICE: table "pg_opclass" was reindexed
NOTICE: table "pg_am" was reindexed
NOTICE: table "pg_amop" was reindexed
NOTICE: table "pg_amproc" was reindexed
NOTICE: table "pg_language" was reindexed
NOTICE: table "pg_largeobject" was reindexed
NOTICE: table "pg_aggregate" was reindexed
NOTICE: table "pg_trigger" was reindexed
NOTICE: table "pg_cast" was reindexed
NOTICE: table "pg_namespace" was reindexed
NOTICE: table "pg_conversion" was reindexed
NOTICE: table "tbl_kenyon" was reindexed
NOTICE: table "test" was reindexed
NOTICE: table "pg_attrdef" was reindexed
NOTICE: table "pg_constraint" was reindexed
NOTICE: table "pg_description" was reindexed
NOTICE: table "pg_proc" was reindexed
NOTICE: table "pg_rewrite" was reindexed
NOTICE: table "pg_type" was reindexed
NOTICE: table "pg_attribute" was reindexed
NOTICE: table "pg_index" was reindexed
NOTICE: table "pg_depend" was reindexed
REINDEX
相关文章推荐
- Oracle重建所有表和索引
- [转贴]在ORACLE里按用户名重建索引的方法
- oracle 10G 表空间迁移 索引需要重建
- 重建索引解决mssql表查询超时的问题
- Oracle表与索引的分析及索引重建
- 在Oracle数据库中按用户名重建索引的方法-开发技术
- 管理索引表:深入研究B树索引--重建,合并,删除(理论篇3)
- Solr之定时重建索引-yellowcong
- 重建索引的考虑
- 关于索引重建
- 重建(重新组织)索引的存储过程
- oracle script: 重建索引
- 数据库单表查询超时,重建索引失败。
- SQL Server索引重建和重新组织脚本
- SQLServer定期重建索引的作业
- 使用游标重建索引
- Oracle重建索引Shell脚本、SQL脚本分享
- oracle 索引什么时候重建和重建方法讨论
- 索引重建
- Oracle中加速索引创建或重建的方法