神秘的 SQL 阻止我的存储过程在 ORACLE 上执行

发布于 2024-09-26 21:39:01 字数 2496 浏览 3 评论 0原文

我正在尝试使用瘦 jdbc 客户端和 c3p0 在 ORACLE 上运行一个过程。

这是应该运行的代码:

        Map<String, Object> paramMap = new HashMap<String, Object>();
        paramMap.put("I_NODE_ID", nodeId);
        paramMap.put("I_PARENT_ID", parentId);
        paramMap.put("I_STRUCTURE_ID", structureId);
        paramMap.put("I_FROM_DATE", beginTime);
        paramMap.put("I_TO_DATE", END_OF_TIME);

        new SimpleJdbcCall(jdbcTemplate).withProcedureName("TC_INSERT_NODE_A").execute(paramMap);

        paramMap.put("I_NOW_DATE", currentTime);
        new SimpleJdbcCall(jdbcTemplate).withProcedureName("TC_INSERT_NODE_B").execute(paramMap);

系统似乎挂起,并且以下查询在企业管理器上显示,占用了我的 CPU 的 100%。

SELECT package_name AS procedure_cat,
       owner AS procedure_schem,
       object_name AS procedure_name,
       argument_name AS column_name,
       DECODE(position,
                0, 5,
                   DECODE(in_out,
                            'IN', 1,
                            'OUT', 4,
                            'IN/OUT', 2,
                                      0)) AS column_type,
       DECODE(data_type,
                'CHAR', 1,
                'VARCHAR2', 12,
                'NUMBER', 3,
                'LONG', -1,
                'DATE', 91,
                'RAW', -3,
                'LONG RAW', -4,
                'TIMESTAMP', 93,
                'TIMESTAMP WITH TIME ZONE', -101,
                'TIMESTAMP WITH LOCAL TIME ZONE', -102,
                'INTERVAL YEAR TO MONTH', -103,
                'INTERVAL DAY TO SECOND', -104,
                'BINARY_FLOAT', 100,
                'BINARY_DOUBLE', 101,
                                 1111) AS data_type,
       DECODE(data_type,
                'OBJECT', type_owner || '.' || type_name,
                          data_type) AS type_name,
       DECODE(data_precision,
                NULL, data_length,
                      data_precision) AS precision,
       data_length AS length,
       data_scale AS scale,
       10 AS radix,
       1 AS nullable,
       NULL AS remarks,
       sequence,
       overload,
       default_value
  FROM all_arguments
  WHERE owner LIKE :1 ESCAPE '/' AND
        object_name LIKE :2 ESCAPE '/' AND
        package_name IS NULL AND
        (argument_name LIKE :5 ESCAPE '/' OR
          (argument_name IS NULL AND data_type IS NOT NULL))
  ORDER BY procedure_schem, procedure_name, overload, sequence

这意味着什么?我应该从哪里开始寻找解决这个问题的方法?

I am trying to run a procedure on ORACLE with the thin jdbc client and c3p0.

here's the code that's supposed to run:

        Map<String, Object> paramMap = new HashMap<String, Object>();
        paramMap.put("I_NODE_ID", nodeId);
        paramMap.put("I_PARENT_ID", parentId);
        paramMap.put("I_STRUCTURE_ID", structureId);
        paramMap.put("I_FROM_DATE", beginTime);
        paramMap.put("I_TO_DATE", END_OF_TIME);

        new SimpleJdbcCall(jdbcTemplate).withProcedureName("TC_INSERT_NODE_A").execute(paramMap);

        paramMap.put("I_NOW_DATE", currentTime);
        new SimpleJdbcCall(jdbcTemplate).withProcedureName("TC_INSERT_NODE_B").execute(paramMap);

The system is seemingly hanging, and the following query appears on Enterprise Manager as taking up 100% of my CPU.

SELECT package_name AS procedure_cat,
       owner AS procedure_schem,
       object_name AS procedure_name,
       argument_name AS column_name,
       DECODE(position,
                0, 5,
                   DECODE(in_out,
                            'IN', 1,
                            'OUT', 4,
                            'IN/OUT', 2,
                                      0)) AS column_type,
       DECODE(data_type,
                'CHAR', 1,
                'VARCHAR2', 12,
                'NUMBER', 3,
                'LONG', -1,
                'DATE', 91,
                'RAW', -3,
                'LONG RAW', -4,
                'TIMESTAMP', 93,
                'TIMESTAMP WITH TIME ZONE', -101,
                'TIMESTAMP WITH LOCAL TIME ZONE', -102,
                'INTERVAL YEAR TO MONTH', -103,
                'INTERVAL DAY TO SECOND', -104,
                'BINARY_FLOAT', 100,
                'BINARY_DOUBLE', 101,
                                 1111) AS data_type,
       DECODE(data_type,
                'OBJECT', type_owner || '.' || type_name,
                          data_type) AS type_name,
       DECODE(data_precision,
                NULL, data_length,
                      data_precision) AS precision,
       data_length AS length,
       data_scale AS scale,
       10 AS radix,
       1 AS nullable,
       NULL AS remarks,
       sequence,
       overload,
       default_value
  FROM all_arguments
  WHERE owner LIKE :1 ESCAPE '/' AND
        object_name LIKE :2 ESCAPE '/' AND
        package_name IS NULL AND
        (argument_name LIKE :5 ESCAPE '/' OR
          (argument_name IS NULL AND data_type IS NOT NULL))
  ORDER BY procedure_schem, procedure_name, overload, sequence

What does this mean? Where should I start looking to solve this problem?

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

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

发布评论

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

评论(1

空气里的味道 2024-10-03 21:39:01

此 SQL 查询存储过程的参数。它看起来效率很低,因为它使用了几个(可能不必要的)LIKE 运算符。这可能会非常慢,特别是如果您的系统有大量 PL/SQL,尤其是 Oracle 11g,对于像这样的元数据查询来说,它会变得慢得多。

Spring 框架是否会在调用存储过程时运行这样的查询(我从未使用过 Spring)?

This SQL queries the parameters of a stored procedure. It looks very inefficient because it uses several (probably unnecessary) LIKE operators. This can be very slow, in particular if you have a system with lots of PL/SQL and in particular with Oracle 11g, which has gotten much slower for meta data queries like this.

Could it be that the Spring framework runs queries like this a part of calling a stored procedure (I've never used Spring)?

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