The "magic" is that they have it all joined with the database that tells them who crossed the other way recently, the flight database or the cruise ship database so it's not searching through millions of passport photos every time. They have a pretty good idea of the search space.