I'm trying to run a query that returns all the posts with a given value for a specific meta key. I know for a fact that this is none of the posts on my test server but it reports finding all the posts with a post count of 7 (there are 21 posts).

I have been following the notes [here][1] and the question [here][2] but I cannot get a sensible outcome.

		$args = array(
				'post_type'  => 'post',
				'meta_query' => array(
					'relation' => 'AND',
					array(
						'key'     => 'perma',
						'compare' => '=', 
						'value'   => "{$raw_perma}"
					),
				),
			);

		// create a custom query
		$my_query = new \WP_Query( $args );
		
		
		echo $my_query->post_count; // 7 (regardless of $raw_perma value).

I would like to know what I am doing wrong. As "are there posts with this meta key-value pair?" seems like it should be a trivial question to answer.

**Update**

Found [another question][3] and tried this:

		$args = array(
				    'posts_per_page'   => -1,
					'post_type'        => 'post',
					'meta_key'         => 'perma',
					'meta_value'       => "{$raw_perma}"
				);

This works although I have no idea why this and not that. Would like to see an explanation in an answer.


  [1]: https://developer.wordpress.org/reference/classes/wp_meta_query/
  [2]: https://wordpress.stackexchange.com/q/80303/109240
  [3]: https://wordpress.stackexchange.com/a/281832/109240