Optimize PartitionDB and CountDB for get_neighbours