[imp] Sql optimise category edit options branch. Fixes #4106