使用 image/varbinary 字段进行联合查询时出现的问题
我在执行以下查询时遇到一些问题:
SELECT v.idnum
,v.full_name
,convert(varbinary(max),s.signature) as Sig
FROM AppDB.dbo.v_People1 AS v INNER JOIN
OtherDB.dbo.Signatures AS s ON v.idnum = s.idnum
UNION
SELECT v.idnum
, v.full_name
, convert(varbinary(max), s.signature) as Sig
FROM AppDB.dbo.v_People2 AS v INNER JOIN
AppDB.dbo.Signatures AS s ON v.idnum = s.idnum
当我在没有联合的情况下单独运行每个查询时,它们会快速执行(<5秒),但是当我使用联合运行它时,它需要永远执行(事实上所有查询)说正在执行。我还没有看到它成功运行)
在 OtherDB.dbo.Signatures 中,签名字段是 varbinary(max) ,在 AppDB.dbo.Signatures 中,该字段是一个图像,这就是我使用转换表达式的原因。 有谁知道问题可能是什么以及我该如何解决它?
谢谢
I'm having some problems with the following Query:
SELECT v.idnum
,v.full_name
,convert(varbinary(max),s.signature) as Sig
FROM AppDB.dbo.v_People1 AS v INNER JOIN
OtherDB.dbo.Signatures AS s ON v.idnum = s.idnum
UNION
SELECT v.idnum
, v.full_name
, convert(varbinary(max), s.signature) as Sig
FROM AppDB.dbo.v_People2 AS v INNER JOIN
AppDB.dbo.Signatures AS s ON v.idnum = s.idnum
When i run them each of the queries separately without the union they execute quickly (<5 seconds), but when i run it using the union it's taking forever to execute (infact all it says is executing. I haven't seen it run successfully)
In OtherDB.dbo.Signatures the signature field is a varbinary(max) and in AppDB.dbo.Signatures the field is an image which is why i am using the convert expression.
Does anyone know what the problem might be and how i can go about fixing it?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我想知道这是否是因为您使用的是 UNION 而不是 UNION ALL。 UNION 本身将删除数据集之间的重复行。这可能会导致您的 blob 字段出现延迟。使用 UNION ALL 看看是否有差异。
I wonder if it's because you are using a UNION instead of a UNION ALL. UNION by itself will remove duplicate rows between the data sets. This may be causing a delay on your blob field. See if there is a difference using UNION ALL.