Refine code and add one parameter to make sure postgresql works after changing configuration

Refine code and add one parameter to make sure postgresql works after changing configuration