Add optimizations for PostgreSQL and Rubby