do not restart postgresql always

Even when the script did nothing, postgresql will be always restarted, which is not necessary and only leads to avoidable downtime.
Do I miss something?