Remove unnecessary sql