Need to update rate_engine query for postgresql