You are here: Re: speeding up inserts « MsSQL Server « IT news, forums, messages
Re: speeding up inserts

Posted by Erland Sommarskog on 03/30/06 00:45

(zelnaga@gmail.com) writes:
> according to the mysql manual, multiple inserts can be sped up by
> locking the table before doing them and unlocking the table afterwards.
>
> is the same true of multiple inserts in mysql? if so, how would the
> table be locked?
>
> any insights would be appreciated - thanks!

In case "mysql" in the second paragraph is a type for MS SQL Server, the
answer is that you cannot really lock a table as such in MS SQL Server,
and definitely not unlock it. You can specify a locking hint to get a
table lock when you insert the first row. Note that you need to have a
user-defined transaction in progress, or else the lock will be released
since statements auto-commit in SQL Server. To "unlock" you simply commit
the transaction.

However, normally you don't play these games for insert statments. It's
better to let SQL Srever choose the locking mode.

If you need to load lots of data, you use BCP (a command-line tool) or
BULK INSERT (an SQL Statement). With these you can specify table lock to
speed up the operation.


--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация