Trafodion 通过maxStatements减少JDBC编译时间

在Trafodion中,我们发现SQL在trafci查看到的数据库实际编译时间很短,不到1ms,但通过JDBC程序的PrepareStatement执行发现每次都需要几毫秒的时间。以下是用JDBC程序执行的输出结果,编译时间的单位为ms,从以下结果可以发现,同样的SQL执行三次,编译时间在2~4ms左右。

===============================Round 1
=======================================
开始时间:3973114842552
prepare后时间:3973117407086
编译时间:2564

===============================Round 2
=======================================
开始时间:3973638578247
prepare后时间:3973642935949
编译时间:4357

===============================Round 3
=======================================
开始时间:3974160244737
prepare后时间:3974164269660
编译时间:4024

通过在JDBC URL添加maxStatements参数,如下

jdbc:t4jdbc://192.168.168.201:23400/:schema=V7FAT;maxStatements=10

maxStatements表示缓存的PrepareStatment对象的个数,值为缓存的条数。默认值为0,表示关闭statement pooling。关于maxStatements可以参照Trafodion JDBC手册http://trafodion.apache.org/docs/jdbct4ref_guide/index.html#maxstatements

5.12. maxStatements Property
The maxStatements property sets the total number of PreparedStatement objects that the connection pool should cache. This total includes both free objects and objects in use.

Set this property on a DataSource object, ConnectionPoolDataSource object, or DriverManager object. For information about how to set properties, see How to Specify JDBC Type 4 Properties.

Data type: int

Units: number of objects

Default: 0 (Disables statement pooling.)

Range: 0 through 2147483647
The value 0 disables statement pooling. Any negative value is treated like 0 (zero).

Example

To specify statement pooling, type:

maxStatements=10

下面是URL添加maxStatements参数后的编译时间输出,从以下结果我们可以发现,JDBC的编译时间得到了巨大的提升。

===============================Round 1
=======================================
开始时间:4034886517149
prepare后时间:4034889063763
编译时间:2546

===============================Round 2
=======================================
开始时间:4034915811537
prepare后时间:4034915886199
编译时间:74

===============================Round 3
=======================================
开始时间:4034936479263
prepare后时间:4034936540699
编译时间:61
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

数据源的港湾

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值