fix logging query performance