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

  • Home
  • SEARCH
  • 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 6683991
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T04:53:12+00:00 2026-05-26T04:53:12+00:00

I am using Entity Framework , and I am inserting records into our database

  • 0

I am using Entity Framework, and I am inserting records into our database which include a blob field. The blob field can be up to 5 MB of data.

When inserting a record into this table, does it lock the whole table?

So if you are querying any data from the table, will it block until the insert is done (I realise there are ways around this, but I am talking by default)?

How long will it take before it causes a deadlock? Will that time depend on how much load is on the server, e.g. if there is not much load, will it take longer to cause a deadlock?

Is there a way to monitor and see what is locked at any particular time?

If each thread is doing queries on single tables, is there then a case where blocking can occur? So isn’t it the case that a deadlock can only occur if you have a query which has a join and is acting on multiple tables?

This is taking into account that most of my code is just a bunch of select statements, not heaps of long running transactions or anything like that.

  • 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-05-26T04:53:13+00:00Added an answer on May 26, 2026 at 4:53 am

    Holy cow, you’ve got a lot of questions in here, heh. Here’s a few answers:

    When inserting a record into this table, does it lock the whole table?

    Not by default, but if you use the TABLOCK hint or if you’re doing certain kinds of bulk load operations, then yes.

    So if you are querying any data from the table will it block until the insert is done (I realise there are ways around this, but I am talking by default)?

    This one gets a little trickier. If someone’s trying to select data from a page in the table that you’ve got locked, then yes, you’ll block ’em. You can work around that with things like the NOLOCK hint on a select statement or by using Read Committed Snapshot Isolation. For a starting point on how isolation levels work, check out Kendra Little’s isolation levels poster.

    How long will it take before it causes a deadlock? Will that time depend on how much load is on the server, e.g. if there is not much load will it take longer to cause a deadlock?

    Deadlocks aren’t based on time – they’re based on dependencies. Say we’ve got this situation:

    • Query A is holding a bunch of locks, and to finish his query, he needs stuff that’s locked by Query B
    • Query B is also holding a bunch of locks, and to finish his query, he needs stuff that’s locked by Query A

    Neither query can move forward (think Mexican standoff) so SQL Server calls it a draw, shoots somebody’s query in the back, releases his locks, and lets the other query keep going. SQL Server picks the victim based on which one will be less expensive to roll back. If you want to get fancy, you can use SET DEADLOCK_PRIORITY LOW on particular queries to paint targets on their back, and SQL Server will shoot them first.

    Is there a way to monitor and see what is locked at any particular time?

    Absolutely – there’s Dynamic Management Views (DMVs) you can query like sys.dm_tran_locks, but the easiest way is to use Adam Machanic’s free sp_WhoIsActive stored proc. It’s a really slick replacement for sp_who that you can call like this:

    sp_WhoIsActive @get_locks = 1
    

    For each running query, you’ll get a little XML that describes all of the locks it holds. There’s also a Blocking column, so you can see who’s blocking who. To interpret the locks being held, you’ll want to check the Books Online descriptions of lock types.

    If each thread is doing queries on single tables, is there then a case where blocking can occur? So isn’t it the case that a deadlock can only occur if you have a query which has a join and is acting on multiple tables?

    Believe it or not, a single query can actually deadlock itself, and yes, queries can deadlock on just one table. To learn even more about deadlocks, check out The Difficulty with Deadlocks by Jeremiah Peschka.

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

Sidebar

Related Questions

Can anyone help? I have been using the entity framework and its going well
EDIT: Duplicate of Should Entity Framework Context be Put into Using Statement? I've been
I'm using entity framework to connect the database. I've a table(Let's call it File)
I'm using Entity Framework 4.0 to access data in a table with a unique
I'm using Entity Framework 4 and with a Database First binding, and EF is
I was developing an application using Entity Framework and storing data in a .mdf
I'm using Entity Framework O/R mapper from Microsoft and using entity classes (generated classes
I am using Entity Framework with my website. To improve performance, I have started
I have a problem with the following Linq query using Entity Framework: from o
When using the Entity Framework, does ESQL perform better than Linq to Entities? I'd

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.