سؤال

My application is using SQL Server 2008 and we need to add functionality for users to optionally be able to save any file of any size to a database table. I have set up the table similar to this format:

  • FileStorageID - int (indentity PK) (This is also a foreign key to a different table)
  • FileData - varbinary(max)
  • FileName - varchar(1000)

The FileStorage table has a zero-to-one relationship to another table Documentation. The idea is that users can write either write some text, upload a file, or both.

This table looks as follows:

  • DocumentationID - int (identity PK, FK to an "IrrelevantInterestingObject" table)
  • Text - varchar(max)
  • FileStorageID - int (FK to aforementioned FileStorage table)

My question is this: When I query the Documentation table using Entity Framework 5, and a file is present in the database, will the entire file be stored in memory? If yes, what would a reasonable threshold be before there is a noticeable performance issue?

هل كانت مفيدة؟

المحلول

If you query Documentation table no data from related FileStorage table will be loaded until you load the relation either through eager, explicit or lazy loading. Once you use any such method or query FileStorage directly whole FileData for every retrieved record will be loaded to memory.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top