When user update a non-thumbnail figure to thumbnail, or insert a new thumbnail, we need to update the old thumbnail to normal figures and set the new figure as thumbnail.
Currently we are doing this with an extra method in service layer called changeThumbnail(), which requires one select + one update. So the total cost of change thmbnail is: one insert/update (for new thumbnail) + (one select + one update) (for old thumbnail).
A better solution is using trigger. When a figure is updated to thumbnail, a script will be triggered to de-thumbnailing the old one if there is one. In this way, the whole cost can be reduced to: one insert/update (for new thumbnail) + one update (for old thumbnail).
Let alone all the network delays.
When user update a non-thumbnail figure to thumbnail, or insert a new thumbnail, we need to update the old thumbnail to normal figures and set the new figure as thumbnail.
Currently we are doing this with an extra method in
service
layer calledchangeThumbnail()
, which requires one select + one update. So the total cost of change thmbnail is:one insert/update (for new thumbnail) + (one select + one update) (for old thumbnail).
A better solution is using trigger. When a figure is updated to thumbnail, a script will be triggered to de-thumbnailing the old one if there is one. In this way, the whole cost can be reduced to:
one insert/update (for new thumbnail) + one update (for old thumbnail).
Let alone all the network delays.