Subject | Re: [ib-support] How Do I count faster? |
---|---|
Author | Ann Harrison |
Post date | 2003-05-26T23:19:22Z |
At 07:31 PM 5/26/2003 -0300, Roque wrote:
a multi-user system. An alternative that does not deadlock is to
count the records once, put that value in a table (e.g.
insert into invoice_count (invoice_count) values (34521);
then store 1 each time a record is added and -1 each time one
is deleted. The count is SUM (invoice_count) FROM INVOICE_COUNT.
To make it fast, you'll need to do a periodic sum, update the
first record, and delete the others.
Regards,
Ann
>:. What about creating a trigger on insert/delete operations toThe problem is that you'll often get deadlocks (lock conflicts) in
>increment/decrement a number in another table? Is that too much expensive to
>the general performance?
a multi-user system. An alternative that does not deadlock is to
count the records once, put that value in a table (e.g.
insert into invoice_count (invoice_count) values (34521);
then store 1 each time a record is added and -1 each time one
is deleted. The count is SUM (invoice_count) FROM INVOICE_COUNT.
To make it fast, you'll need to do a periodic sum, update the
first record, and delete the others.
Regards,
Ann