Fixing primary key and index search