Subject | RE: [firebird-support] IS this the right thing to do (trigger) |
---|---|
Author | Leyne, Sean |
Post date | 2008-11-20T20:33:18Z |
Robert,
SET AvailableRecs = AvailableRecs **+** 1
Sean
> OverviewWhat is the frequency of running the counts query?
> I have a large table (5 - 20 million records) that I regularly need to
> do grouped counts on. this is slow. My planned solution is to have a
> counting table updated by triggers. I would like to know what people
> think of the following proposed solution. Will it work properly, what
> sort of performance hit will be involved, is there a better way?
> And the following triggers to maintain totals....I think you really meant:
> CREATE TRIGGER BranchSend_Edit FOR BranchSend
> AFTER EDIT POSITION 10
> AS BEGIN
> IF (OLD.TransferConfirmed = 'F')
> AND (New.TransferConfirmed = 'T') THEN
>
> UPDATE BranchSendCount
> SET AvailableRecs = AvailableRecs - 1
> WHERE RegionRef = NEW.RegionRef
> AND SendTable = NEW.SendTable;
SET AvailableRecs = AvailableRecs **+** 1
Sean