创建从 Microsoft SQL Server 到 AS/400 的连接
我正在尝试从 Microsoft SQL Server 连接到 AS/400,以便我可以从 AS/400 提取数据,然后将数据标记为正在提取。
我已经成功创建了 OLE DB“IBMDASQL”连接,并且能够提取一些数据,但是当我尝试从一个非常大的表中提取数据时遇到问题
这运行正常,并返回计数1.7 亿:
select count(*)
from transactions
这个查询执行了 15 个小时,然后我就放弃了。 (它应该返回零,因为我还没有将任何内容标记为“正在处理”)
select count(*)
from transactions
where processed = 'In process'
我是 Microsoft 人员,但我的 AS/400 人员说“已处理”列上有一个索引,并且在本地,该查询瞬间运行。
关于我可能做错了什么有什么想法吗?我找到了一个只有 68 条记录的表,并且能够在大约一秒钟内运行此查询:
select count(*)
from smallTable
where RandomColumn = 'randomValue'
所以我知道 AS/400 至少能够理解该类型的查询。
I'm trying to connect from Microsoft SQL server to as AS/400 so i can pull data from the AS/400 then flag the data as being pulled.
I've successfully created and OLE DB "IBMDASQL" connection, and am able to pull data some data, but i'm running into an issue when i try to pull data from a very large table
This runs fine, and returns a count of 170 million:
select count(*)
from transactions
This query executed for 15 hours before i gave up on it. (It should return zero since i haven't flagged anything as 'in process' yet)
select count(*)
from transactions
where processed = 'In process'
I'm a Microsoft guy, but my AS/400 guy says that there is an index on the 'processed' column and that locally, that query run instantaneously.
Any thoughts on what i might be doing wrong? I found a table with only 68 records in it, and was able to run this query in about a second:
select count(*)
from smallTable
where RandomColumn = 'randomValue'
So I know that the AS/400 is at least able to understand that type of query.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
这场战斗我已经打过很多次了。
有两种方法可以解决这个问题。
1) 将数据从 AS400 暂存在 SQL Server 中,您可以在其中优化索引
2)要求AS400人员创建逻辑视图来加速数据检索,你的AS400程序员是正确的,索引会有所帮助,但我忘记了他们用来定义类似于sql server视图的“视图”的术语,我相信它是这样的“物理”与“逻辑”。逻辑性就是你想要的。
第三,1.7亿条记录是很多记录,即使对于像SQL Server这样的关系数据库,您是否考虑过每晚运行一个SSIS包,将您的数据暂存到您自己的SQL表中,看看是否可以提高性能?
I have had to fight this battle many times.
There are two ways of approaching this.
1) Stage your data from the AS400 into SQL server where you can optimize your indexes
2) Ask the AS400 folks to create logical views which speed up data retrieval, your AS400 programmer is correct, index will help but I forget the term they use to define a "view" similar to a sql server view, I beleive its something like "physical" v/s "logical". Logical is what you want.
Thirdly, 170 million is a lot of records, even for a relational database like SQL server, have you considered running an SSIS package nightly that stages your data into your own SQL table to see if it improves performance?
我建议这种方式具有良好的性能,我想你至少有
SQL2005
,我还没有测试过,但这是一个提示让AS400通过创建存储过程以本机方式执行选择在AS400中
以这种方式创建一个AS400存储过程来获取/更新记录集
创建一个AS400存储过程来更新记录集
从SQL SERVER调用那些AS400 SP
希望有帮助
I would suggest this way to have good performance, i suppose you have at least
SQL2005
, i havent tested yet but this is a tipLet the AS400 perform the select in native way by creating stored procedure in the AS400
create an AS400 stored procedure in this way to get/update the recordset
create an AS400 stored procedure to update the recordset
Call those AS400 SP from SQL SERVER
Hope it helps
我建议遵循 IBM 红皮书 SQL Performance Diagnosis on IBM DB2 Universal Database for iSeries 中的建议 以确定到底发生了什么。
IBM 技术支持对于诊断此类问题也非常有帮助。不要害怕与他们联系,因为软件支持通常包含在维护合同中,并且与他们交谈是免费的。
我见过 OLEDB 连接在几个小时内耗尽 100% 的 cpu,并且当通过 VisualExplain(查询分析器)运行相同的查询时,它估计只需几秒钟即可执行。
I recommend following the suggestions in the IBM Redbook SQL Performance Diagnosis on IBM DB2 Universal Database for iSeries to determine what's really happening.
IBM technical support can also be extremely helpful in diagnosing issues such as these. Don't be afraid to get in touch with them as the software support is generally included as part of the maintenance contract and there is no charge to talk to them.
I've seen OLEDB connections eat up 100% cpu for hours and when the same query is run through VisualExplain (query analyzer) it estimates mere seconds to execute.
我们发现像这样运行查询的效果与预期一致:
We found that running the query like this performed liked expected:
这可能是排序问题吗? - 您的
WHERE
子句正在文本字段上进行测试,如果两个服务器的排序规则不匹配,则该子句将应用于客户端而不是服务器端,因此您首先需要拉取所有 1.7 亿条记录到客户端,然后对其执行WHERE
子句。Could this be a collation problem? - your
WHERE
clause is testing on a text field and if the collations of the two servers don't match this clause will be applied clientside rather than serverside so you are first of all pulling all 170 million records down to the client and then performing theWHERE
clause on it there.根据我过去的交互,无论您如何访问数据,查询都应该花费大约相同的时间。另一个想法是,您是否可以在表上创建视图来获取所需的数据或使用存储过程。
Based on the past interactions I have had, the query should take about the same amount of time no matter how you access the data. Another thought would be if you could create a view on the table to get the data you need or use a stored procedure.