Improved filtering and count performance