Показать сообщение отдельно
Старый 31.03.2007, 15:17   #1  
SHiSHok is offline
SHiSHok
Участник
Аватар для SHiSHok
Дети Юза
 
219 / 103 (4) +++++
Регистрация: 28.07.2005
Адрес: Донецк
Lightbulb тупость при удалении из InventJournalTrans
удаляли сегодня инвентаризационный журнал,я громко матюкался когда обнаружил этот тупняк (88000 строк журнала удалялось 4 часа).
итак таблица: InventJournalTrans
X++:
void delete()
{
    ;
    ttsbegin;
    appl.inventUpdateTTSControl().setTTSBeginLock();

    super();

    if (this.journalType == InventJournalType::Count)
        InventItemLocation::updateStopCountingJournal(this);

    InventUpd_DeleteMovement::newMovement(InventMovement::construct(this)).updateNow();

    if (this.voucher)
    {
        if (this.numOfVoucherLines() == 0) // нас интересует эта строка !!!
            JournalError::deleteVoucher(tableNum(InventJournalTable),this.journalId,this.voucher);
    }

    appl.inventUpdateTTSControl().setTTSCommitLock();
    ttscommit;

}
смотрим метод numOfVoucherLines()
X++:
Integer numOfVoucherLines()
{
    return (select forceplaceholders count(recId) from inventJournalTrans
                index hint VoucherIdx
                where inventJournalTrans.journalId == this.journalId &&
                      inventJournalTrans.voucher   == this.voucher).recId;
}
т.е. для того чтобы узнать есть такие строки или нет мы считаем их количество! и так для каждой строки журнала - я офигел . сделал так:
X++:
// SHiSHok 20070331
boolean voucherLineExist()
{
    return (select firstfast firstonly forceplaceholders recId from inventJournalTrans
            index hint VoucherIdx
            where inventJournalTrans.journalId == this.journalId &&
                  inventJournalTrans.voucher   == this.voucher).recId != 0;
}

void delete()
{
    ;
    ttsbegin;
    appl.inventUpdateTTSControl().setTTSBeginLock();

    super();

    if (this.journalType == InventJournalType::Count)
        InventItemLocation::updateStopCountingJournal(this);

    InventUpd_DeleteMovement::newMovement(InventMovement::construct(this)).updateNow();

    if (this.voucher)
    {
//        if (this.numOfVoucherLines() == 0)  //
        if (!this.voucherLineExist())
            JournalError::deleteVoucher(tableNum(InventJournalTable),this.journalId,this.voucher);
    }

    appl.inventUpdateTTSControl().setTTSCommitLock();
    ttscommit;

}
при удалении подобного журнала на тестовой выдало оценочное время 35мин (грубо говоря в 6 раз прирост производительности)
__________________
--- SHiSHok
За это сообщение автора поблагодарили: mazzy (5), belugin (6), kashperuk (3), konopello (2), fialka (1), bobski (1).