开发者

nHibernate talking a long time to save binary data

开发者 https://www.devze.com 2023-04-12 08:20 出处:网络
I am attempting to store files in an SQL se开发者_高级运维rver database using the filestream column type and nHibernate.

I am attempting to store files in an SQL se开发者_高级运维rver database using the filestream column type and nHibernate.

It seems to work however it is VERY slow, I have tried changing this to just a regular varbinary(max) column and it has no effect.

Testing on a local site using a local database... saving a ~100k file takes about 5-10 seconds, saving a ~5mb file takes 20-30 minutes.

Looking at SQL profilers it seems that it is taking nHibernate that long to push out the insert statement and not an issue with the DB.

It spikes up about 80mb of memory on iis when trying to commit but the processor is not being hit at all, it just sits there.

Has anybody experienced this before or has any insights before I debug into nHibernate source?

Here is my configuration...

public class ProgramDocument : IDocumentFile
{
    public virtual int ProgramDocumentId { get; set; }
    public virtual Program Program { get; set; }
    public virtual byte[] DocumentData { get; set; }
    public virtual ProgramDocumentationType DocumentType { get; set; }
    public virtual string MimeType { get; set; }
    public virtual string FileExtension { get; set; }
    public virtual ProgramPresenter ProgramPresenter { get; set; }
    public virtual DateTime CreateDate { get; set; }
}

public class ProgramDocumentOverride : IAutoMappingOverride<ProgramDocument>
{
    public void Override(AutoMapping<ProgramDocument> mapping)
    {
        mapping.Map(_ => _.DocumentData).Length(int.MaxValue).LazyLoad();
    }
}

Thanks, Brian W.


I suspect the problem is due to the fact that NH try to check if the binary field has changes, and this take longer than just saving. I remember there was such an issue in the past and I did not remember the workaround, or if it was solved. Try to check the jira: https://nhibernate.jira.com/secure/Dashboard.jspa

0

精彩评论

暂无评论...
验证码 换一张
取 消