use optimized query as option, logging first and then test with logging result