PostgreSQL创建物化视图并刷新

1、创建物化视图

--视图hnqyhxv_person
CREATE  MATERIALIZED  VIEW hnqyhxv_person  TABLESPACE  sys_default  as  
SELECT 
	*
FROM E_PRI_PERSON WHERE LEREPSIGN = '1'

2、创建视图索引

--创建索引
CREATE INDEX index_hnqyhxv_person_pripid ON hnqyhxv_person(pripid);

3、查看索引

select * from pg_indexes where tablename = 'hnqyhxv_person'

PostgreSQL创建物化视图并刷新_第1张图片

4、刷新物化视图(会锁住视图,刷新较快)

 

refresh materialized view hnqyhxv_person;

5、刷新物化视图(不会锁住视图,刷新速度大幅下降)

refresh materialized view concurrently hnqyhxv_person;

你可能感兴趣的:(pgsql,数据库,postgresql)