避免在 Oracle 过程中频繁调用同一视图 [英] Avoiding frequent call to same view inside a Oracle procedure

查看:44
本文介绍了避免在 Oracle 过程中频繁调用同一视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 oracle 视图,它从不同的表返回 500 万条记录,我使用此视图使用单个过程插入不同的表,在此过程中我多次使用它,这会影响性能,有什么办法我们可以查询一次视图,然后我可以在多个地方使用它?

I have a oracle view it returns 5 million records from different tables and i use this view to insert into different tables using a single procedure, inside this procedure i use this several times and this is affecting the performance, is there any way we can query the view once and later i can use it multiple places?

推荐答案

视图是一个存储查询;本身,它不包含任何数据.如果它的代码很复杂并且从多个表中获取数据,使用不同的条件、聚合等,访问数据可能需要一些时间.

A view is a stored query; itself, it doesn't contain any data. If its code is complex and fetches data from several tables, using different conditions, aggregations, whatnot, it can take some time to access data.

在您的情况下,全局(或私有;取决于您使用的 Oracle 版本)临时表 (GTT) 可能会有所帮助.

In your situation, maybe a global (or private; depending on Oracle version you use) temporary table (GTT) would help.

  • 一次创建
  • 在程序开始时,将视图中的数据插入其中
  • 剩下的过程将使用那些准备好的数据
  • 一旦会话(或事务;取决于您设置 GTT 的方式)结束,表中的数据就会丢失
    • 下次运行程序时可以重复使用该表

    这篇关于避免在 Oracle 过程中频繁调用同一视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆