1 million pair using 16 MB is about 16 bytes per pair, which is perfectly fine but nothing impressive. The dataset is static, so a simple naive solution would be to create a big array sorted by key. Assuming both photo and user IDs use 4 bytes each, this would result in about 2GB of data. Then use binary search to lookup values. However, if we really want to reduce the size, we could build a finite state machine from…
If I read the article correctly, existing entries won't change but new entries will be inserted.