Re: Deleting Records

Поиск
Список
Период
Сортировка
От Christopher Kings-Lynne
Тема Re: Deleting Records
Дата
Msg-id 43575C5D.3030301@familyhealth.com.au
обсуждение исходный текст
Ответ на Deleting Records  ("Christian Paul B. Cosinas" <cpc@cybees.com>)
Список pgsql-performance
> Here is the code inside my function:
>
>     FOR temp_rec IN SELECT * FROM item_qc_doer LOOP
>         DELETE FROM qc_session WHERE item_id = temp_rec.item_id;
>         DELETE FROM item_qc_doer WHERE item_id = temp_rec.item_id;
>     END LOOP;
>
> Item_qc_oder table contains 22,000 records.

Also, chekc you have an index on both those item_id columns.

Also, why don't you just not use the loop and do this instead:

DELETE FROM qc_session WHERE item_id IN (SELECT item_id FROM item_qc_doer);
DELETE FROM item_qc_doer;

Chris


В списке pgsql-performance по дате отправления:

Предыдущее
От: Matteo Beccati
Дата:
Сообщение: Re: Deleting Records
Следующее
От: "Steinar H. Gunderson"
Дата:
Сообщение: Re: Materializing a sequential scan