Re: delete is getting hung when there is a huge data in table
В списке pgsql-general по дате отправления:
| От | Andomar |
|---|---|
| Тема | Re: delete is getting hung when there is a huge data in table |
| Дата | |
| Msg-id | 5545E0F8.3060805@aule.net обсуждение исходный текст |
| Ответ на | delete is getting hung when there is a huge data in table (Mitu Verma <mitu.verma@ericsson.com>) |
| Список | pgsql-general |
> Now issue is that when this script for the deletion of data is
launched , it is taking more than 7 days and doing nothing i.e not a
single row has been deleted.
Deleting a large number of rows can take a long time. Often it's
quicker to delete smaller chunks. The LIMIT clause is not supported by
DELETE, so you need some kind of subquery.
We use something like:
do $_$declare
num_rows bigint;
begin
loop
delete from YourTable where id in
(select id from YourTable where id < 500 limit 100);
get diagnostics num_rows = row_count;
raise notice 'deleted % rows', num_rows;
exit when num_rows = 0;
end loop;
end;$_$;
This deletes rows with an id smaller than 500 in chunks of 100.
Kind regards,
Andomar
В списке pgsql-general по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера