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?
1条答案
按热度按时间btxsgosb1#
If you query
Documentation
table no data from relatedFileStorage
table will be loaded until you load the relation either through eager, explicit or lazy loading. Once you use any such method or queryFileStorage
directly wholeFileData
for every retrieved record will be loaded to memory.