Add logging and temp query length measure