当我选择在SQL Server的varbinary(max)
列中保存的图像时,我遇到了延迟问题,选择至少5张图像大约需要3-5分钟。该表(galleryDetail
)包含大小不同的图像,例如2mb,40kb和1mb。正如此链接SQL server slow select query from type varbinary(max)(最后评论)中所建议的那样,如果有人可以给我一个路线图/建议,以完成此任务,那将是很大的帮助。
我的表结构如下,
CREATE TABLE [dbo].[GalleryDetail]
(
[Id] [INT] IDENTITY(1,1) NOT NULL,
[Image] [VARBINARY](MAX) NULL,
[Title] [VARCHAR](250) NULL,
[Active] [BIT] NULL,
[CreatedDate] [DATETIME] NULL,
CONSTRAINT [PK_ImageGallery]
PRIMARY KEY CLUSTERED ([Id] ASC)
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
ALTER TABLE [dbo].[GalleryDetail]
ADD CONSTRAINT [DF_GalleryDetail_Active] DEFAULT ((1)) FOR [Active]
GO
答案 0 :(得分:0)
如果按标题列选择,然后添加索引以使选择更快:
create index idx_Title on dbo.GalleryDetail(Title)
这仅在标题位于查询的where子句中时才有帮助,例如
select * from GalleryDetail where Title = 'My picture'
或
select * from GalleryDetail where Title like 'picture%'