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'

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

refresh materialized view hnqyhxv_person;

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

refresh materialized view concurrently hnqyhxv_person;

猜你喜欢

转载自blog.csdn.net/weixin_41542329/article/details/128241715
今日推荐