Re: Delete query taking long time to execute
- From: Hugo Kornelis <hugo@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Fri, 24 Nov 2006 00:37:06 +0100
On Wed, 22 Nov 2006 04:30:01 -0800, Somesh wrote:
hi,
I have a table which is a Master to other 12 tables and it is Child for
other 2 tables.
Therefore, It has 14 relationships with other tables. The size of table is
very small. (approx 30-40 rows). It also has a clustered index in its primary
key.
The problem I am facing here is that when I try to delete a row from the
table using its primary key in where clause, it takes more than 30 seconds to
execute it. Any subsequent attempt will be of a shorter duration (approx
20-25 sec.) but still it is very time taking.
I can't understand what could be the problem here when the table size is
very small. Is it because of constraints or any other sort.
Hi Somesh,
Indeed. The size of this table is not the problem. The number of tables
referencing this table (12), the size of the referencing tables, and the
indexing of those tables is.
For the DELETE to succeed, each of the 12 "Child" tables has to be
checked since the DELETE may not leave any orphins. The FOREIGN KEY
constraints in those tables do not automatically create an index, so if
you have not done so, this check requires a table scan.
--
Hugo Kornelis, SQL Server MVP
.
- Prev by Date: Re: Delete query taking long time to execute
- Next by Date: Re: Delete query taking long time to execute
- Previous by thread: Re: Delete query taking long time to execute
- Index(es):
Relevant Pages
|
|