如何使用varbinary列提高SQL Server表的性能?

时间:2018-02-20 22:05:58

标签: sql-server database-performance query-performance varbinary varbinarymax

我的数据库中有一个表用作文件存储,文件本身存储在varbinary(MAX)列中。

CREATE TABLE [dbo].[FILE_TABLE](
    [FILE_ID] [int] IDENTITY(1,1) NOT NULL,
    [HTML_FILE] [nvarchar](max) NULL,
    [XML_FILE] [varbinary](max) NULL,
    [FILE_EXTENSION] [nvarchar](50) NULL
 CONSTRAINT [PK_FILE_TABLE] PRIMARY KEY CLUSTERED 
(
    [FILE_ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 80) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO

我们还创建了以下非聚集索引:

CREATE NONCLUSTERED INDEX [NonClusteredIndex-20180220-000116] ON [dbo].[FILE_TABLE]
(
    [FILE_ID] ASC
)
INCLUDE (   [XML_FILE]) WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO

此表启用了语义和freetext,可以对文档运行关键字搜索。当我们运行简单的自由文本查询时,性能非常慢。该表仅包含810条记录,返回713行需要30秒。我们怎样才能提高这个表或查询的性能?

SELECT * FROM FILE_TABLE WHERE freetext(XML_FILE,'lights')

0 个答案:

没有答案