简体   繁体   English

ruby OCI8缓慢初始化

[英]ruby OCI8 slow initialization

I'm developing API for product based on Oracle database and I tried to use ruby-oci8 gem, but I faced a strange problem - OCI8.new is very slow, it takes 1,2-1,5 second to connect to database. 我正在开发基于Oracle数据库的产品API,我尝试使用ruby-oci8 gem,但我遇到了一个奇怪的问题--OCI8.new非常慢,连接数据库需要1,2-1,5秒。

For example: 例如:

~ mmulev$ irb
2.1.1 :001 > require 'oci8'
 => true 
2.1.1 :002 > def test
2.1.1 :003?>   t0 = Time.now
2.1.1 :004?>   OCI8.new('SCHEMA', 'STRONG_PASS', '//db_host:port/service_name')
2.1.1 :005?>   Time.now - t0
2.1.1 :006?>   end
 => :test 
2.1.1 :007 > test
 => 1.217809 
2.1.1 :008 >

The same thing in php (oci_new_connect) needs approximately 0,1-0,2 second to establish connection and return handler. php(oci_new_connect)中的相同内容需要大约0,1-0,2秒来建立连接和返回处理程序。

Is there any other solutions besides connection pooling? 除了连接池之外还有其他解决方案吗?

PS ruby API code was profiled by method_profiler and by Benchmark, oracle v - 11g PS ruby​​ API代码由method_profiler和Benchmark,oracle v - 11g进行了分析

You can also use this gem to connect to oracle 您也可以使用此gem连接到oracle

https://github.com/rsim/oracle-enhanced https://github.com/rsim/oracle-enhanced

Make sure that you have installed oracle properly you can install this by following link : How to install ruby-oci8? 确保您已正确安装oracle,您可以通过以下链接安装如何安装ruby-oci8?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM