rewrite the primary key compare code

rewrite the primary key compare code