Added debug logging of query plan.