我用spring编写了一个api,用表类型作为输入paremter和number out参数调用存储过程。当我打电话给这个api时,大约需要2分钟才能得到结果。但……
最后搜索了很多并实现了几个场景。我发现在使用表类型时需要实现一件事来提高性能;
1)我们需要使用数组描述符和结构描述符来创建表类型而不是使用对象数组。
OracleConnection connection = uploadCall.getJdbcTemplate().getDataSource().getConnection().unwrap(OracleConnection.class); StructDescriptor desc1=StructDescriptor.createDescriptor("XX_TYP",connection); ArrayDescriptor desc2=ArrayDescriptor.createDescriptor("XX_TAB",connection); Object[] p1arrobj = new Object [uploadList.size()]; for(int i=0;i<orderList.size();i++) { Object [] p1recobj = {orderList.get(i).getId(),orderList.get(i).getType()}; STRUCT p1struct = new STRUCT(desc1,connection,p1recobj); p1arrobj[i]=p1struct; } ARRAY p1arr = new ARRAY(desc2,connection,p1arrobj);