fix slow query