Re: DELETE FROM - Somethings not right
- From: "David Portas" <REMOVE_BEFORE_REPLYING_dportas@xxxxxxx>
- Date: 25 Feb 2006 01:33:55 -0800
nnelson wrote:
I have a base customer table of 2 million records. We're doing some
testing and I added 33000 rows incorrectly. No biggie, we'll just
delete them, right? Nope....9 hours later, process is still running
using this query.
delete from customer where custid in (select custid from #tmp1)
k...so we'll change it.
delete from customer where custid > 2295885
2 hours later, still going slower than a turtle...literally 1 row per
second.
custid is my primary key so you can't tell me it's not indexed. It's
pretty bad when I have to resort to doing a restore of my entire
database of 27GB because it's faster than deleting 33000 rows.
WTF?
Do you have any unindexed foreign key's referencing the table? Not
indexing foreign keys can seriously hurt DELETE performance.
--
David Portas, SQL Server MVP
Whenever possible please post enough code to reproduce your problem.
Including CREATE TABLE and INSERT statements usually helps.
State what version of SQL Server you are using and specify the content
of any error messages.
SQL Server Books Online:
http://msdn2.microsoft.com/library/ms130214(en-US,SQL.90).aspx
--
.
- References:
- DELETE FROM - Somethings not right
- From: nnelson
- DELETE FROM - Somethings not right
- Prev by Date: Party time: 75% discount for Database Workbench licenses!
- Next by Date: Re: long SQL lines for osql
- Previous by thread: Re: DELETE FROM - Somethings not right
- Next by thread: Re: DELETE FROM - Somethings not right
- Index(es):
Relevant Pages
|