Improve sql usage