improve sql mapping queries