数据表数据量接近4000万,表中只有主键索引无其他索引,创建物化视图进行预查询过滤

数据表数据量接近4000万,表中只有主键索引无其他索引,创建物化视图进行预查询过滤

--每次查询往往只需要4000万条中的几百条数据,因此先创建物化视图过滤并得到一个几千到几万条数据的结果,并 创建监听动态更新。

 

 

drop materialized view log on fs_budgetpayout_detail ;    --不是view名,是表名

create materialized view  mv_fs_budgetpayout_detail	--创建物化视图 mv_fs_budgetpayout_detail
  build immediate
  refresh fast
  on commit
  enable query rewrite
  as  
  select t.fiscal, t.co_code, t.project_code, t.outlay_code , sum(t.payout_amt) payout_amt
   from fs_budgetpayout_detail t
  where t.period != 0
  and t.period != 13
  group by t.fiscal, t.co_code, t.project_code,t.outlay_code
    

create materialized view log on fs_budgetpayout_detail with rowid,sequence(payout_amt,fiscal,co_code,project_code,period,outlay_code) including new values;

  

posted @ 2019-06-26 10:18  GL_BKY  阅读(441)  评论(0编辑  收藏  举报