Improve trends query