Refactor appending of SQL comments

Description

There's a couple of optimisations that we can do in case SQL comments are enabled. Details coming in the PR.

Environment

None

Assignee

Sanne Grinovero

Reporter

Sanne Grinovero

Fix versions

None

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Priority

Minor
Configure