adding some db related optimizations