[英]ruby-odbc slow connect times for DB2 ODBC driver
Every time the code is executed, it takes 30 seconds each time for ODBC.connect
to establish a connection to the data source. 每次执行代码时, ODBC.connect
每次ODBC.connect
花费30秒建立与数据源的连接。
When running the same sql statement via isql -v mustship
it takes .01 seconds to execute and finish so I know its something on this server or maybe I'm doing something wrong with my actions below? 通过isql -v mustship
运行同isql -v mustship
sql语句时,执行和完成操作需要0.01秒,因此我知道此服务器上的某些内容,或者我的以下操作有问题吗? I read the ruby-odbc docs pretty carefully and didn't see anything surround this. 我非常仔细地阅读了ruby-odbc文档,却没有发现任何东西。
class MustshipsController < ApplicationController
require 'odbc'
def index
mustshiptl = ODBC.connect("mustship", '', '')
sql = "SELECT COL1, COL2, COL3, COL4 FROM MUSTSHIPTL"
stmt = mustshiptl.run(sql)
# code execution here
stmt.drop
end
Help is appreciated 感谢帮助
I figured this out. 我想通了。
If you use CurrentSchema=libraryname
in your db2cli.ini file for IBM DB2 data sources the execution will be delayed while it sets the access path in DB2 to just this library. 如果您在db2cli.ini文件CurrentSchema=libraryname
用于IBM DB2数据源,则在将DB2中的访问路径设置为此库时,执行将被延迟。 Removing this setting brought me back to milliseconds of execution time. 删除此设置使我回到执行时间的毫秒数。 Then you just need to define the library name for each table in sql call. 然后,您只需要为sql调用中的每个表定义库名。
Hope this helps in case somebody runs into this in the future. 希望这对将来有帮助的人有所帮助。 Very frustrating. 非常沮丧。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.