|
Posted by David Portas on 02/25/06 11:33
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
--
Navigation:
[Reply to this message]
|