WHERE 子句中的文件流列锁定服务器

发布于 2025-01-06 03:16:32 字数 1283 浏览 1 评论 0原文

我已经在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

沫尐诺 2025-01-13 03:16:32

首先,如果您想查询 VARBINARY 列,您需要启用并使用全文搜索。

参考文章。

First and foremost if you want to query a VARBINARY column you'll need to enable and use Full-Text Search.

Reference Articles.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文