idoutils: fix bad update performance with large commenthistory table

Refs #4985
Merge branch 'fix/commenthistory-idx-4985' into next

Fixes #4985