0

I would like to know how the concurrency works in SQL Server Express database.

The reason I am asking this is because testing my database to be used to create an email server which can send multiple email campaigns at the same time, I noticed that when inserting into the Log table the results of the emails, one campaign is sent before the other starts (I tested with 5 emails on each), resulting in the log being: c1-1, c1-2, c1-3, c1-4, c1-5, c2-1, c2-2, c2-3, c2-4, c2-5.

Besides that, I noticed that simply running 2 queries, to insert 1000 rows on a table, the queries will wait for the previous one to finish.

I googled and also searched StackOverflow for the reason this happens, but couldn't find a clear answer, everywhere it's said what I am trying to do can be done, but I can't seem to do it.

Thanks.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Kurumas
  • 1
  • 1
  • 2
    Read [Locking in the Database Engine](http://msdn.microsoft.com/en-us/library/ms190615(v=sql.105).aspx) and [Managing Concurrent Data Access](http://msdn.microsoft.com/en-us/library/ms189130(v=sql.105).aspx), including all the sub-chapters. – Remus Rusanu May 13 '13 at 15:14
  • it says taht for read it's a shared lock, so shouldn't it at least let me read the same table on concurrent queries? – Kurumas May 13 '13 at 15:22
  • Also, the situation I described using the Log, the inserts are made separately, so shouldn't the lock be removed as soon as one insert is made, letting the other campaign insert one row? – Kurumas May 13 '13 at 15:27
  • 1
    I don't believe you've read the linked articles and sub-chapters, they're long enough to take at least 2-3 hours to read. – Remus Rusanu May 13 '13 at 15:43
  • Sorry, but I've read it all, didn't quite understand. I didn't get how to change it, because it says it's automatic, but when I verified the locks that are happening to my DB, all of them are DB level, even if I read a single row, it is locking the whole DB for the time it took to read that single row. Unless I didn't understand how to check the locks that are happening. – Kurumas May 13 '13 at 17:55

0 Answers0