最近遇到一个问题,需求是把大量的数据写入到第三方数据库oracle,目前用的是EnsLib.SQL.OutboundAdapter 方案,但是感觉队列很容易卡死,不知道是什么原因。然后想换成 set res = ##class(%ResultSet).%New("%DynamicQueryGW:SQLGW") 这种方式执行插入和更新。但是它返回的错误是网关调用失败,我希望得到具体的错误,我用这个对应额sql语句去 navicat执行就能提示出明确的错误!有大佬处理过类似的问题吗?有更好的方案吗?
产品版本: Ensemble 2016.1
$ZV: Cache for Windows (x86-64) 2016.2.3 (Build 907_11_20446U) Thu Nov 12 2020 16:56:45 EST
//Create new Gateway connection object set gc=##class(%SQLGatewayConnection).%New() If gc=$$$NULLOREF quit $$$ERROR($$$GeneralError,"Cannot create %SQLGatewayConnection.")
//Make connection to target DSN s pDSN="Cache Samples" s usr="_system" s pwd="SYS" set sc=gc.Connect(pDSN,usr,pwd,0) If $$$ISERR(sc) quit sc if gc.ConnectionHandle="" quit $$$ERROR($$$GeneralError,"Connection failed")
set sc=gc.AllocateStatement(.hstmt) if $$$ISERR(sc) quit sc
//Prepare statement for execution set pQuery= "insert into scott.dept (deptno,dname,loc) values (10,'Customer Support','Tokyo')" set sc=gc.Prepare(hstmt,pQuery) if $$$ISERR(sc) quit sc //Execute statement set sc=gc.Execute(hstmt) if $$$ISERR(sc) { Set xsc=gc.GetErrorList(hstmt,.err) Zwrite err Quit err }
您好,通常对于第三方的数据库连接,最常见的性能问题的根源在于平台一侧的数据吞吐量大于对方数据库接收数据的能力,在使用BO及OutboundAdapter时,可以观察到消息队列拥堵,尤其是低业务量下顺畅,高业务量下出现队列快速拥堵的情况下,几乎可以肯定是对端数据库的性能缺陷。
在这种情况下,由于堵点不在平台而在数据库,在平台侧的所有优化都解决不了问题,只能保障平台不因对端数据库的拥堵崩溃。可选的处理手段有:
1. 最终用户根据数据库的吞吐量降低整个平台的吞吐量
2. 最终用户要求保障平台吞吐量,但对端数据库无法优化,则需要接受在平台中堆积队列的现实
3. 最终用户要求保障平台吞吐量,对端数据库改进性能以满足平台吞吐的需要
建议对方的数据库性能进行基准性能和压力测试,使得平台和数据库在吞吐量上相互适应
打印对端数据库的出错信息,可参考
//Create new Gateway connection object
set gc=##class(%SQLGatewayConnection).%New()
If gc=$$$NULLOREF quit $$$ERROR($$$GeneralError,"Cannot create %SQLGatewayConnection.")
//Make connection to target DSN
s pDSN="Cache Samples"
s usr="_system"
s pwd="SYS"
set sc=gc.Connect(pDSN,usr,pwd,0)
If $$$ISERR(sc) quit sc
if gc.ConnectionHandle="" quit $$$ERROR($$$GeneralError,"Connection failed")
set sc=gc.AllocateStatement(.hstmt)
if $$$ISERR(sc) quit sc
//Prepare statement for execution
set pQuery= "insert into scott.dept (deptno,dname,loc) values (10,'Customer Support','Tokyo')"
set sc=gc.Prepare(hstmt,pQuery)
if $$$ISERR(sc) quit sc
//Execute statement
set sc=gc.Execute(hstmt)
if $$$ISERR(sc)
{
Set xsc=gc.GetErrorList(hstmt,.err)
Zwrite err
Quit err
}