Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8305739
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T18:11:04+00:00 2026-06-08T18:11:04+00:00

For a recent MVC3 project I ended up storing files in an MSSQL database

  • 0

For a recent MVC3 project I ended up storing files in an MSSQL database as byte[] (MVC3 turns this into a varbinary(max) column).

Once files are committed to the database, they will NEVER change.

Now im trying to be real clever and avoid storing the same file multiple times even if users add the same file over and over again.

My first idea for avoiding this was to create a where query to try to find if there is an existing match for the byte[] I’m trying to add. I’m however worried that this is too heavy of a query as files can be around 100Mb in size, and there can be multiple people adding them at the same time.

To try to be even more clever I could use some information about the file to narrow the search. I currently have the following relevant columns in the model.

public byte[] FileData { get; set; }        
public String MimeType { get; set; }
public double FileSizeMb { get; set; }

I could search for if there are any files with the same mime type and file size as well as possibly adding a hash of the byte[] too see if i can get a match off those before I try to match the byte[]. That way im only comparing when I have a file with the right size of the right type and the same hash, which should be less heavy..

Are there any better options to accomplish this? How would I best solve this problem?

If it’s any difference I’m using mssql 2012.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T18:11:06+00:00Added an answer on June 8, 2026 at 6:11 pm

    You should compute hash of your FileData (on web server side, of course), and search using hash and file size. If you have a match, you should download FileData to web server and compare (not the other way around).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

A recent project called for importing data into an Oracle database. The program that
A recent project made use of very pixel-large (~5e3px2) but still byte-small (~100kb —
In several recent answers I see this code given as the way to retrieve
A recent mention of PostSharp reminded me of this: Last year where I worked,
A recent crash prompted this question - I had two gui windows open. Is
The recent ATL security update updated the C++ runtimes to version 8.0.50727.4053. Unfortunately, this
For a recent project incorporated FancyBox and overall am happy with it. A friend
I have been working on a small project on recent delived ASP.NET MVC 3
A recent project has called for the use of two Hiragino fonts on iOS
Recent conversations with colleagues have produced varying points of view on this matter. What

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.