HELP !!! Delete row takes forever
-
- Уже с Приветом
- Posts: 347
- Joined: 11 May 2001 09:01
- Location: NJ
HELP !!! Delete row takes forever
Dear community
First of all sorry for English.
There is SQL Server 7.0 on Window NT server
Table A ( about 200 000 rows) is parent for 7 others with rows counts from 1 mln. to 12 mln. rows each
Need to be deteted some information from A. There is list PK of table A for this . Those PK has no childs. ( triple checked)
Usual record takes 1 second to delete, but for some of then takes forever ( never waited more then 10 minutes) . What could be possible reason ?
So far I have one solution : create new table copy there all valid records from A. Then drop table A and recorevere all partnership. But that is too long . Server is slow.
Any ideas how it can be done faster or how to delete problem records ?
Any ideas are welcome
Thanks in advance
First of all sorry for English.
There is SQL Server 7.0 on Window NT server
Table A ( about 200 000 rows) is parent for 7 others with rows counts from 1 mln. to 12 mln. rows each
Need to be deteted some information from A. There is list PK of table A for this . Those PK has no childs. ( triple checked)
Usual record takes 1 second to delete, but for some of then takes forever ( never waited more then 10 minutes) . What could be possible reason ?
So far I have one solution : create new table copy there all valid records from A. Then drop table A and recorevere all partnership. But that is too long . Server is slow.
Any ideas how it can be done faster or how to delete problem records ?
Any ideas are welcome
Thanks in advance
-
- Уже с Приветом
- Posts: 28294
- Joined: 29 Aug 2000 09:01
- Location: SPB --> Gloucester, MA, US --> SPB --> Paris
1. Проверьте что для всех FK существуют индесы котоыре их поддерживают
2. ЧТо такое 'иногда'
Не является ли случай с 'irregular selectivity'
Например, когда Вы удаляете row вы удаляете 10 rows в detail tables
Но для значения например "N/A', вы удаляете миллион
2. ЧТо такое 'иногда'
Не является ли случай с 'irregular selectivity'
Например, когда Вы удаляете row вы удаляете 10 rows в detail tables
Но для значения например "N/A', вы удаляете миллион
Зарегистрированный нацпредатель, удостоверение N 19719876044787 от 22.09.2014
-
- Уже с Приветом
- Posts: 347
- Joined: 11 May 2001 09:01
- Location: NJ
Dmitry, thanks
There is NO single FK for records I would like to detele. I checked this 3 times. These records were just loaded and now manager would like me to delete them.
Some records means
There are PKs for table A
1,2,3,4
delete from A where pk_id = 1
takes 1 sec
delete from A where pk_id = 2
takes 1 sec
delete from A where pk_id = 3
.... in 10 minutes it was not completed . Canceled
delete from A where pk_id = 4
took 1 sec
There is NO single FK for records I would like to detele. I checked this 3 times. These records were just loaded and now manager would like me to delete them.
Some records means
There are PKs for table A
1,2,3,4
delete from A where pk_id = 1
takes 1 sec
delete from A where pk_id = 2
takes 1 sec
delete from A where pk_id = 3
.... in 10 minutes it was not completed . Canceled
delete from A where pk_id = 4
took 1 sec
-
- Уже с Приветом
- Posts: 550
- Joined: 31 Mar 2000 10:01
- Location: Moscow --> Baltimore, MD
RedHot wrote:Dmitry, thanks
There is NO single FK for records I would like to detele. I checked this 3 times. These records were just loaded and now manager would like me to delete them.
Some records means
There are PKs for table A
1,2,3,4
delete from A where pk_id = 1
takes 1 sec
delete from A where pk_id = 2
takes 1 sec
delete from A where pk_id = 3
.... in 10 minutes it was not completed . Canceled
delete from A where pk_id = 4
took 1 sec
А что произойдет, если после этого опять сделать
delete from A where pk_id = 3
?
В смысле, повторяется ли проблема на одних и тех же записях?
-
- Уже с Приветом
- Posts: 347
- Joined: 11 May 2001 09:01
- Location: NJ
-
- Уже с Приветом
- Posts: 8249
- Joined: 23 Jul 2003 03:53
- Location: SPb - KW - NY - CT - MD
RedHot wrote:Yes. That is why I am asking for your advice. Server just cannot delete with PK = 3 .
I have checked with DBCC CHECKTABLE all related tables. It was slow but returned no errors.
Все выглядит так, что там и нет никаких ошибок, а просто значительно большее количество записей (DELETE CASCADE?) в дочерних таблицах конкретно для PK=3. Или действительно какой-нибудь индекс пропал для одного из FK?
LG - Life's good.
But good life is much better.
But good life is much better.
-
- Уже с Приветом
- Posts: 550
- Joined: 31 Mar 2000 10:01
- Location: Moscow --> Baltimore, MD
-
- Уже с Приветом
- Posts: 347
- Joined: 11 May 2001 09:01
- Location: NJ
-
- Уже с Приветом
- Posts: 550
- Joined: 31 Mar 2000 10:01
- Location: Moscow --> Baltimore, MD
-
- Уже с Приветом
- Posts: 347
- Joined: 11 May 2001 09:01
- Location: NJ
-
- Уже с Приветом
- Posts: 28294
- Joined: 29 Aug 2000 09:01
- Location: SPB --> Gloucester, MA, US --> SPB --> Paris
Я бы посмотрел чем сервер занимается когда идет удаление
Одинков ли exec plan ?
Сколько записей собираются удаляться ? Что если сделать select
Отключите паралелизм
Еще раз посмотрите план удаления что касается child таблиц
Приведите публике текстовый план
Одинков ли exec plan ?
Сколько записей собираются удаляться ? Что если сделать select
Отключите паралелизм
Еще раз посмотрите план удаления что касается child таблиц
Приведите публике текстовый план
Зарегистрированный нацпредатель, удостоверение N 19719876044787 от 22.09.2014
-
- Уже с Приветом
- Posts: 347
- Joined: 11 May 2001 09:01
- Location: NJ
Selects are realy slow on some child tables but no problem with select on main table. Some child tables have over 2000% of cost into plan and actual excution of plain select takes up to 2 minutes.
I tried to place plan here be it hard to read something into wrap lines.
Unfortunately there are no any "good" records left, so nothing to compare with.
However, I will just do as I planed before and post result . There is no mirracle, something just wrong.
Sorry to trouble you and thanks to all and everyone personaly for your support
I tried to place plan here be it hard to read something into wrap lines.
Unfortunately there are no any "good" records left, so nothing to compare with.
However, I will just do as I planed before and post result . There is no mirracle, something just wrong.
Sorry to trouble you and thanks to all and everyone personaly for your support
-
- Уже с Приветом
- Posts: 28294
- Joined: 29 Aug 2000 09:01
- Location: SPB --> Gloucester, MA, US --> SPB --> Paris
-
- Уже с Приветом
- Posts: 108
- Joined: 14 Apr 2004 00:39
- Location: Находка-Ванкувер-Калгари
Re: HELP !!! Delete row takes forever
RedHot wrote:Dear community
Запускай профайлер и гляди что там происходит.
-
- Уже с Приветом
- Posts: 1099
- Joined: 30 Sep 1999 09:01
- Location: Bryansk,RUSSIA >> Dublin, Ireland
-
- Уже с Приветом
- Posts: 109
- Joined: 26 Sep 2002 12:24
-
- Уже с Приветом
- Posts: 28294
- Joined: 29 Aug 2000 09:01
- Location: SPB --> Gloucester, MA, US --> SPB --> Paris
-
- Уже с Приветом
- Posts: 550
- Joined: 31 Mar 2000 10:01
- Location: Moscow --> Baltimore, MD
-
- Уже с Приветом
- Posts: 28294
- Joined: 29 Aug 2000 09:01
- Location: SPB --> Gloucester, MA, US --> SPB --> Paris
-
- Уже с Приветом
- Posts: 550
- Joined: 31 Mar 2000 10:01
- Location: Moscow --> Baltimore, MD
-
- Уже с Приветом
- Posts: 4412
- Joined: 06 Nov 2003 17:03
- Location: TX
-
- Уже с Приветом
- Posts: 28294
- Joined: 29 Aug 2000 09:01
- Location: SPB --> Gloucester, MA, US --> SPB --> Paris
-
- Уже с Приветом
- Posts: 4412
- Joined: 06 Nov 2003 17:03
- Location: TX
-
- Уже с Приветом
- Posts: 347
- Joined: 11 May 2001 09:01
- Location: NJ
Problem was fixed almost itself.
I waited until everybody left office and rebooted server , which was running for more then a year without reboot. After box was up, problem records were deleted in regular 1 sec time frame for each.
So I don't know what was the actual problem
We do have indexes on FK and gather statistics once a week
One more time thanks for concern and attention to my problem
I waited until everybody left office and rebooted server , which was running for more then a year without reboot. After box was up, problem records were deleted in regular 1 sec time frame for each.
So I don't know what was the actual problem
We do have indexes on FK and gather statistics once a week
One more time thanks for concern and attention to my problem