Bulk update of item types

We're changing the vast majority of our stock from 1 week and 4 week loans to 2 weeks this summer as part of a project to ensure more access to texts. So, I need to change the item types of the majority of our 150,000 item stock. On first thoughts, this SQL seems about right:

update ITEM
set TYPE_ID = 21 (2 WEEK LOANS)
where TYPE_ID = 1 (4 WEEK LOANS)

And the same for 1 week loans. Can it really be that easy?

updating the ITEM table

In theory yes it is that simple but the situation is complicated by the fact that there are triggers on the ITEM table. These triggers update the ITEM_UPDATE table so that changes to items can be processed for OPAC collections and for other processes. These triggers required the use of temporary tables as part of the update process. This means a lot more work is being done than you might expect.

There is no real effect where it is one item updated and even 100 probably wouldn't be noticable but as the number of updates increase so does the time taken. It could be hours for a relatively small number of updates. For 150000 updates it will be very noticable although I cannot give an estimate.

We find that it is actually quicker to script item updates so only one update is done at a time in a loop or to do the updates for items in batches e.g.

update ITEM
set TYPE_ID = 21
where TYPE_ID = 1
where ITEM_ID between 1 and 1000

The size of batches does depend on the number ond spread of the items affected through the ITEM table.

For more details of the triggers and the implications there is an article called Bulk updates of the ITEM table

In addition as with any database update I would test any SQL/scripts fully on the MIS server first.

Thanks

Brian Crampton
Developer, Talis

Thanks Brian - I'll take

Thanks Brian - I'll take your advice and script it to run in batches on the MIS first.