SQL and host model optimization