Is a table locked every time I insert something in it? Because I want to insert thousands of rows each second so I want to know if having more than one thread for inserting helps effectively or not. If each insert locks the table just one thread is almost as efficient as for example 10 threads.
If it depends on the Database engine, I use SQL Server 2008.
Is a table locked every time I insert something in it? Because I want
Share
VoidPointer isn’t necessarily correct. He isn’t necessarily incorrect either. It depends why you have a multi-threaded application. If the threads are purely designed as a mechanism to ‘insert more data’ then no it probably won’t improve performance. If however the threads serve some other purpose, then it suggests your latency is maybe elsewhere in the system and you shouldn’t be worrying too much about the database. Why have you got all these threads? Presumably you’re trying to make some other operation more efficient – like multiple I/O bound calls that complete at unknown intervals but reduce overall latency to the length of the longest running thread? Without a bit more context on what you’re trying to achieve and why, you can’t simply pronounce that a multi-threaded solution is wrong.
Have a look at some of the locking hint options SQL Server supports..
I think SQL Server supports concurrent INSERTs