moved with_connection block outside instrument to avoid adding resource waiting time to query times