WHERE 子句中的文件流列锁定服务器
我已经在 SQL Server 2008 r2 上的现有数据库中实现了文件流。
现在我有一个非常紧迫的问题,因为我的网站实际上已经关闭了:
有一个非常简单的表,如下所示:
CREATE TABLE [dbo].[Table1](
[Id] [int] IDENTITY(1,1),
[rowguid] [uniqueidentifier] ROWGUIDCOL NOT NULL,
[Image] [varbinary](max) FILESTREAM NULL,
CONSTRAINT [PK_Table1] PRIMARY KEY CLUSTERED
(
[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF,
ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
CONSTRAINT [Table1RowguidUnique] UNIQUE NONCLUSTERED
(
[rowguid] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF,
ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
ALTER TABLE [dbo].[Table1] ADD CONSTRAINT [DF_table1_rowguid] DEFAULT (newid()) FOR [rowguid]
GO
ALTER TABLE dbo.Table1
SET ( FILESTREAM_ON = fsfg_LiveWebsite )
GO
如果我运行:
select * from Table1 where Id = 1
它运行得非常快并给出正确的结果。 如果我在 where 子句中使用“Varbinary(max) FILESTREAM”字段运行任何内容,则整个表都会锁定。 例如,这两个查询中的任何一个:
select Id from Table1 where Id = 1 and [Image] is null
select Id from Table1 where Id = 1 and [Image] = convert(varbinary(max), 'a')
这可能是什么?
有任何建议请尽快回复!
谢谢
I have implemented filestream in an existing database on SQL Server 2008 r2.
Now I have a very urgent problem as my site is practically down now:
With a very simple table like this:
CREATE TABLE [dbo].[Table1](
[Id] [int] IDENTITY(1,1),
[rowguid] [uniqueidentifier] ROWGUIDCOL NOT NULL,
[Image] [varbinary](max) FILESTREAM NULL,
CONSTRAINT [PK_Table1] PRIMARY KEY CLUSTERED
(
[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF,
ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
CONSTRAINT [Table1RowguidUnique] UNIQUE NONCLUSTERED
(
[rowguid] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF,
ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
ALTER TABLE [dbo].[Table1] ADD CONSTRAINT [DF_table1_rowguid] DEFAULT (newid()) FOR [rowguid]
GO
ALTER TABLE dbo.Table1
SET ( FILESTREAM_ON = fsfg_LiveWebsite )
GO
If I run:
select * from Table1 where Id = 1
it runs very quickly and give the correct result.
If I run anything with the "Varbinary(max) FILESTREAM" field in the where clause the whole table locks down.
So for example any of those 2 queries:
select Id from Table1 where Id = 1 and [Image] is null
select Id from Table1 where Id = 1 and [Image] = convert(varbinary(max), 'a')
What could this be?
Please reply asap with any suggestion!
Thank you
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先,如果您想查询 VARBINARY 列,您需要启用并使用全文搜索。
参考文章。
First and foremost if you want to query a VARBINARY column you'll need to enable and use Full-Text Search.
Reference Articles.