awk working with large files
Maybe comm, which is part of GNU coreutils, is more efficient.

comm writes to standard output lines that are common, and lines that are unique, to two input files; a file name of ‘-’ means standard input. Synopsis:
comm [option]… file1 file2

In your case you could sort both files based on the first 3 columns:
file1=file1.vcf
file2=file2.vcf

comm -12 &lt;(awk '{print $1,$2,$3}' $file1 | sort) \
         &lt;(awk '{print $1,$2,$3}' $file2 | sort) &gt; matches


# result:
cat matches
1 10366 rs58108140
1 51954 rs185832753
#CHROM POS ID

This could be of course polished by removing the header.
Also if you want the original lines as output, you can grep the matches to the original files:
grep -f matches file1
#CHROM POS ID REF ALT QUAL 
1 10366 rs58108140 G A
1 51954 rs185832753 G C

Edit: In the first version, intermediate temp files were used, but as suggested by terdon in the comments, this can be avoided using Process Substitution allowing the &lt;(..) contstruct.