Click to See Complete Forum and Search --> : Performance: rs.update vs if
Patzer
October 18th, 2001, 02:28 AM
Hi,
maybe one of you knows this (hope this question is not too stupid):
A recordset is open (function imports data from another database), where 10 fields of a record may have been changed by the user. Ususally at one Session only a very small percentage of the records in fact have been changed, and only one or two fields.
I could check if there was a change,
and update only if thats true, or I could update every record.
My question now is: Which Idea should have a higher performance?
have a nice day,
Patzer
Cimperiali
October 18th, 2001, 02:42 AM
Fastest should be:
as user changes a value in a record, mark that record.
Then build up a Sql statement for updating records whits some changes.
Sql is faster than editing with ado. Updating fiew records is faster than updating all. Updating some fileds is faster than updating the whole record (but idf you have to update two records with different fields, better execute a single Sql statement for the whole fileds of the two records than two sql for separate fields...)
Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood, TCartwright, Bruno Paris, Dr_Michael
and all the other wonderful people who made and make Codeguru a great place.
Come back soon, you Gurus.
The Rater
Patzer
October 18th, 2001, 03:02 AM
Hi,
concerning the update of records: as I have no influence on the database where I import the data from, I cannot mark the updated record
concerning the update of fields: it's obvious that the update of fields lasts some time, but a possible if-statement lasts some time too, and if I include 10 times an if-statement to check if fields in the record have changed, the win in performance of avoiding the update may be (over)comensated by the several if-statements. So to be more precise, how many if statements do I need to compensate an update?
have a nice day,
Patzer
Cimperiali
October 18th, 2001, 03:27 AM
Now, matter is:
in memory operations are faster than disk one. So, in general, you may have several "if" and be quicker in any case. But it all depends on free resources: when your Os needs (every MilliSecond on MS Os), it will "swap" 'nd "page", which means "he will write to disk"... So, how many?
As you already know, the less, the quicker... And there are other factors involved (like position of DB -if remote or local- speed of lan, etc.)
You should make some trial on your own sistem...
;)
Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood, TCartwright, Bruno Paris, Dr_Michael
and all the other wonderful people who made and make Codeguru a great place.
Come back soon, you Gurus.
The Rater
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.