使用Varray查询中查询结果缓存

发布于 2025-02-13 04:40:56 字数 2843 浏览 0 评论 0 原文

测试#1:

我有一个查询,可以成功调用查询结果缓存提示:/ *+ result_cache */

with data (id) as (
  select 1 from dual union all
  select 2 from dual
)
select /*+ result_cache */
    id
from
    data

解释计划中的第2行显示了使用的结果缓存:

-----------------------------------------------------------------------------------------------
| Id  | Operation        | Name                       | Rows  | Bytes | Cost (%CPU)| Time     |
-----------------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT |                            |     2 |     6 |     4   (0)| 00:00:01 |
|   1 |  RESULT CACHE    | 478vfsvhadjt55zu0vzbphb9f5 |       |       |            |          |
|   2 |   VIEW           |                            |     2 |     6 |     4   (0)| 00:00:01 |
|   3 |    UNION-ALL     |                            |       |       |            |          |
|   4 |     FAST DUAL    |                            |     1 |       |     2   (0)| 00:00:01 |
|   5 |     FAST DUAL    |                            |     1 |       |     2   (0)| 00:00:01 |
-----------------------------------------------------------------------------------------------
 
Result Cache Information (identified by operation id):
------------------------------------------------------
 
   1 - column-count=1; name="..."

测试#2:

下一个查询是相同的,除了我添加了一个varray列:

with data (id, my_array) as (
  select 1, sys.odcivarchar2list('a', 'b', 'c') from dual union all
  select 2, sys.odcivarchar2list('d', 'e') from dual
)
select /*+ result_cache */
    id,
    my_array
from
    data

解释计划显示结果cache 不使用

-------------------------------------------------------------------------
| Id  | Operation        | Name | Rows  | Bytes | Cost (%CPU)| Time     |
-------------------------------------------------------------------------
|   0 | SELECT STATEMENT |      |     2 |    74 |     4   (0)| 00:00:01 |
|   1 |  VIEW            |      |     2 |    74 |     4   (0)| 00:00:01 |
|   2 |   UNION-ALL      |      |       |       |            |          |
|   3 |    FAST DUAL     |      |     1 |       |     2   (0)| 00:00:01 |
|   4 |    FAST DUAL     |      |     1 |       |     2   (0)| 00:00:01 |
-------------------------------------------------------------------------


80cdeba823f423f43ef4ca4601684bbc6ca4

”使用查询结果的方法具有Varray列的查询中的缓存?

我不想在将Varray元素作为字符串中提取的解决方法。我希望在我的查询中使用适当的Varray列以及其他复杂数据类型(例如SDO_GEOMETRY)。

Test #1:

I have a query that successfully invokes the Query Result Cache hint: /*+ result_cache */.

with data (id) as (
  select 1 from dual union all
  select 2 from dual
)
select /*+ result_cache */
    id
from
    data

Line 2 in the explain plan shows the RESULT CACHE being used:

-----------------------------------------------------------------------------------------------
| Id  | Operation        | Name                       | Rows  | Bytes | Cost (%CPU)| Time     |
-----------------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT |                            |     2 |     6 |     4   (0)| 00:00:01 |
|   1 |  RESULT CACHE    | 478vfsvhadjt55zu0vzbphb9f5 |       |       |            |          |
|   2 |   VIEW           |                            |     2 |     6 |     4   (0)| 00:00:01 |
|   3 |    UNION-ALL     |                            |       |       |            |          |
|   4 |     FAST DUAL    |                            |     1 |       |     2   (0)| 00:00:01 |
|   5 |     FAST DUAL    |                            |     1 |       |     2   (0)| 00:00:01 |
-----------------------------------------------------------------------------------------------
 
Result Cache Information (identified by operation id):
------------------------------------------------------
 
   1 - column-count=1; name="..."

Test #2:

The next query is the same, except I've added a varray column:

with data (id, my_array) as (
  select 1, sys.odcivarchar2list('a', 'b', 'c') from dual union all
  select 2, sys.odcivarchar2list('d', 'e') from dual
)
select /*+ result_cache */
    id,
    my_array
from
    data

The explain plan shows that the RESULT CACHE isn't being used.

-------------------------------------------------------------------------
| Id  | Operation        | Name | Rows  | Bytes | Cost (%CPU)| Time     |
-------------------------------------------------------------------------
|   0 | SELECT STATEMENT |      |     2 |    74 |     4   (0)| 00:00:01 |
|   1 |  VIEW            |      |     2 |    74 |     4   (0)| 00:00:01 |
|   2 |   UNION-ALL      |      |       |       |            |          |
|   3 |    FAST DUAL     |      |     1 |       |     2   (0)| 00:00:01 |
|   4 |    FAST DUAL     |      |     1 |       |     2   (0)| 00:00:01 |
-------------------------------------------------------------------------

db<>fiddle


Question:

Is there a way to use the Query Result Cache in query that has a varray column?

I'd don't want to use a workaround where I extract the varray elements as a string. I'm hoping to use a proper varray column in my query, as well as other complex datatypes like SDO_GEOMETRY.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

筱武穆 2025-02-20 04:40:56

看起来collection列不受result_cache的支持。

在rel =“ nofollow noreferrer”> oracle 18c- result_cache

的限制

result_cache在带有或输入参数的功能上不允许。

result_cache在具有 或返回参数(或包含)这些类型的函数上不允许:

  • blob

  • clob

  • nclob

  • 参考光标

  • 收集

  • 对象

  • 记录或PL/SQL集合,其中包含不支持的返回类型

result_cache在匿名块中不允许在功能上。

result_cache在管道表函数上不允许并嵌套
功能。

It looks like collection columns aren't supported by the RESULT_CACHE.

Oracle 18c - Restriction on RESULT_CACHE

RESULT_CACHE is disallowed on functions with OUT or IN OUT parameters.

RESULT_CACHE is disallowed on functions with IN or RETURN parameter of (or containing) these types:

  • BLOB

  • CLOB

  • NCLOB

  • REF CURSOR

  • Collection

  • Object

  • Record or PL/SQL collection that contains an unsupported return type

RESULT_CACHE is disallowed on function in an anonymous block.

RESULT_CACHE is disallowed on pipelined table function and nested
function.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文