The global $wp_query
object is not what you are looking for by the time you get to single.php. Instead use global $wp
object. Try changing your code to this:
global $wp;
if (array_key_exists('myvar', $wp->query_vars) && isset($wp->query_vars['myvar'])){
echo 'custom variable recognized';
}
print_r($wp->query_vars);