Whats Faster??

MiniMe
Posts: 210
Joined: Thu Mar 15, 2001 4:30 pm

Whats Faster??

Post by MiniMe »

Is it faster to update a record or to delete and re-insert the record.??
User avatar
John
Site Admin
Posts: 2623
Joined: Mon Apr 24, 2000 3:18 pm
Location: Cleveland, OH

Whats Faster??

Post by John »

Generally the update, as it only has one SQL to process, and may (depending on the update) have to change fewer indices.
John Turnbull
Thunderstone Software
MiniMe
Posts: 210
Joined: Thu Mar 15, 2001 4:30 pm

Whats Faster??

Post by MiniMe »

Hmm.. I have a peice of code that looks like below. But it only inserts records at 6-7 per second.. Would a unique index on one of the columns slow it significantly??

<sql "delete from tempadds">
Processing $BN
<SQL NOVARS "insert into bookstemp values(counter, $Userid, $UsRec,
'', $LDT,
$Family, $AA, $TI, $AI, $PU, $PP, $DP,
$ED, $BD, $CN, $NC, $CI, $BN, $PR, $PA, $SC, $QTY, $NT, $MT,
$KE,$WB,$WT,$WA,$FE,$FD,$FC,$FS,$WI,$WG,$WF,$WL,$WD,$CB,$CJ,$WC,$II);">
</SQL>
</sql>
User avatar
John
Site Admin
Posts: 2623
Joined: Mon Apr 24, 2000 3:18 pm
Location: Cleveland, OH

Whats Faster??

Post by John »

You probably should use ROW as an attribute on the DELETE, so that it doesn't end up with all of tempadds in memory. The rate will depend on the number of indices on the two tables, as well as the size of the data that you are deleting and inserting.

Whether an index is unique or not will not change the insert rate if the records are unique.
John Turnbull
Thunderstone Software