petebristol
Programmer
Dear All,
Please can you help/advise on the best way forward?
Assume I have a single table, containing 22 fields - 1 * varchar(10) for Productno (key field), 1 * varchar(10) for location (Unique for product, but potentially duplicated across products) and 20 * numeric(18,2) containing various numerical ratios, figures etc.
There are approxiamtely 300 products in the table each having up to 20 locations i.e max of 6000 records in total.
The database table is being updated in real time by about 5 users each updating at most 10 products a day each (using an linked Excel spreadsheet). There is almost a zero % chance that any two users will attempt to update the SAME product at the SAME time.
Of the following two scenarios, Which is the best way to update this table? When I say *best*, this might be the "fastest" way if it makes a significant difference or it might be the "safest" if again there is a big difference in realibility.
1. Using an UPDATE table query on only those fields that have changed (this will be between 50%-75% of them most of the time)i.e.
UPDATE table
SET field3 = new value,
SET field4 = new value
...
WHERE product = 'xxx' and location = 'yyy'
for each of the locations
or
2. Dont bother to write each change seperately but get rid of all records and then insert new ones i.e.
DELETE FROM table //Get rid of them all each time
WHERE product = 'xxx'
Followed by
INSERT INTO table VALUES (.....) //Insert all new values even though some may not have changed.
I have tried both scenarios, each appearing to work equally as well from a performance point of view and neither obviously putting any kind of strain on the SQL2000 database so I am keen to do what is "best".
Many thanks for any help offered.
Regards,
Pete
Please can you help/advise on the best way forward?
Assume I have a single table, containing 22 fields - 1 * varchar(10) for Productno (key field), 1 * varchar(10) for location (Unique for product, but potentially duplicated across products) and 20 * numeric(18,2) containing various numerical ratios, figures etc.
There are approxiamtely 300 products in the table each having up to 20 locations i.e max of 6000 records in total.
The database table is being updated in real time by about 5 users each updating at most 10 products a day each (using an linked Excel spreadsheet). There is almost a zero % chance that any two users will attempt to update the SAME product at the SAME time.
Of the following two scenarios, Which is the best way to update this table? When I say *best*, this might be the "fastest" way if it makes a significant difference or it might be the "safest" if again there is a big difference in realibility.
1. Using an UPDATE table query on only those fields that have changed (this will be between 50%-75% of them most of the time)i.e.
UPDATE table
SET field3 = new value,
SET field4 = new value
...
WHERE product = 'xxx' and location = 'yyy'
for each of the locations
or
2. Dont bother to write each change seperately but get rid of all records and then insert new ones i.e.
DELETE FROM table //Get rid of them all each time
WHERE product = 'xxx'
Followed by
INSERT INTO table VALUES (.....) //Insert all new values even though some may not have changed.
I have tried both scenarios, each appearing to work equally as well from a performance point of view and neither obviously putting any kind of strain on the SQL2000 database so I am keen to do what is "best".
Many thanks for any help offered.
Regards,
Pete