Optimize performance for partitions check