Re: Insert or update ??
Posted in 1999
>I need some inputs on performance in following scenarios : > >Scenario 1 >I have a table say t1. This table has 11 fields and 4 indexes (Record size : >180 bytes). >I read records from this table and depending on some condition I have to set >a expired flag for that record. Currently this table does not have a expired >flag field. >I have another table say t2 which stores the expired flag. This table has 2 >indexes (Record Size : 15). > >Whenever the condition for expiry has matched, the process INSERTs the >record in table t2. > >Scenario 2 >Add a expired flags field to table t1 above. Now, whenever the expiry >condition is matched the process will set the expired flag as TRUE for the >record currently read and UPDATE the record in the database. >In this case I no longer need the table t2. > >Which scenario will give better performance ? It depends on a lot of different factors. I doubt there'll be a great deal in the insert vs update, insert might be marginally slower because there'll be a an index entry which might not be an issue on the update. But when you read the data back, the single-table solution will almost certainly be faster. HTH. ______________________________________________________ Get Your Private, Free Email at http://www.hotmail.com