优化查询:DBMS_METADATA.GET_DDL(Oracle) [英] Optimizing query: DBMS_METADATA.GET_DDL (Oracle)

查看:203
本文介绍了优化查询:DBMS_METADATA.GET_DDL(Oracle)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想获取所有表的所有表定义。
而且我想快速完成它(它是我运行很多的脚本的一部分)

I want to get all table definition for all my tables. And I want to do it fast (it is part of a script that I'm running a lot)

我正在使用oracle 11g,我有700张桌子。在一个普通的jdbc代码上需要4分钟并且确实:

I am using oracle 11g, and I have 700 tables. On a plain jdbc code it takes 4 minutes and does:

s = con.statement("select DBMS_METADATA.GET_DDL(object_type,object_name) from user_objects where object_type = 'TABLE');
s.execute();
rs = s.getResultSet();
while(rs.next()){
 rs.getString(1);
}

所以我想优化这段代码达到大约20秒。

SO I want to optimize this code and reach around 20 sec.

我已经通过创建14个线程达到40-50秒,每个线程打开一个与数据库的连接并读取部分信息,使用mod在rownum上。

I have already reached 40-50 sec by creating 14 threads that each opens a connection to the database and reads a part of the information, using mod on the rownum.

但这还不够。

我正在考虑这些方向:


  1. http://docs.oracle.com/cd/B10501_01/java.920/a96654/connpoca.htm#1063660 - 连接缓存。它可以通过替换来帮助加快速度我与connectionCaching的14个连接?

  1. http://docs.oracle.com/cd/B10501_01/java.920/a96654/connpoca.htm#1063660 - connection caching. can it help speed up things by replacing my 14 connections with connectionCaching?

是否可以在KEEP缓冲区缓存区域中保留此函数访问的表?

Is it possible to keep the tables accessed by this function, in the KEEP buffer cache area?

无论如何将索引中的某些信息编入索引?

Anyway of indexing some of the information here?

我们非常感谢任何其他建议。

Any other suggestions will be greatly appreciated.

谢谢

推荐答案

恐怕没有什么比这更容易了。整个GET_DDL事务是用Java实现的,并使用XSLT转换作为生成过程的一部分。

I'm afraid there is no easy to make it faster. The whole GET_DDL thing is implemented in Java and uses XSLT transformation as a part of generation process.

也许你会发现这更快。
http://metacpan.org/pod/DDL::Oracle

Maybe you will find this faster. http://metacpan.org/pod/DDL::Oracle

这篇关于优化查询:DBMS_METADATA.GET_DDL(Oracle)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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