Subject Re: [firebird-support] Performance Question
Author Alexandre Benson Smith
Todd E. Brasseur wrote:

>Hello,
>
>We have one table in our application that gets alot of hits. We are
>having problems with corrupted indexes in this table.
>
>
Todd,

What FB version, and wich SO are you using ?

Corrupted indices, or corrupted DB in general, should not occurr, even
if that table are getting smashed by a lot of activity. I think the
cause of corruption is not the amount of update (or insert or delete) on
a given table.

>My question is:
>
>Is it more efficient to delete records and then insert new records or to
>update existing records multiple times?
>
>
>For example: (primary 1 and primary 2 make up the primary key on the table)
>
>Primary1 Primary2 Value
>1 1 10
>1 2 50
>1 3 60
>
>needs to be changed to:
>
>1 1 20
>1 2 60
>
>There is a fairly complex calculation that is coded in a stored
>procedure to come up with the values. The number of records can vary.
>
>Is it better to:
>
>1) Delete the three records
>2) Insert the two records
>
>Or to:
>
>1) Update all records to value of 0
>2) Calculate the values and change existing records (or insert new
>records if need be)
>3) Delete any records that still have a value of 0
>4) This method will typically have alot of updates and not very many
>inserts and deletes.
>
>
>I hope this makes sense. In actuality, the data is more complex, but I
>feel the example shows what we are after.
>
>Any information regarding the best course of action would be appreciated.
>
>

If you are updating the same record multiple times will be slower than
insert a record with the final value, but if you insert the value with
an intermediate value and then continues to update the same record, this
case should be slow. I think if you delete the record and then insert a
record with the final value will be slower than update the value with
the final value.

>Todd
>
>
I think you are trying the wrong approach to solve your corruption problem.

see you !

--

Alexandre Benson Smith
Development
THOR Software e Comercial Ltda.
Santo Andre - Sao Paulo - Brazil
www.thorsoftware.com.br