In MongoDB client side fields level encryption, When we encrypt records and have multiple data encryption keys(please don't confuse this with master key) in key vault, if we fetch multiple records in a single query, say X records which have 1 field encrypted using Y distinct data encryption keys, I would like to understand how the driver handles fetching of these data encryption keys. I could think of few ways listed below on how it could have been handled, but want to understand exact behaviour to finalise our approach.
If anyone has idea on how its implemented, please share.
TIA
I have tried it out myself by generating 3 data encryption keys(DEKs) and multiple records(R) encrypted using these and stored in DB. When I fetched all the records, it made a query to fetch all 3 DEKs using an $in query on the 3 DEK IDs. So, looks like its following scenario 3. This observation is for small set of data. May be if there are too many DEKs, it might try to make different batch calls for DEKs, not sure. But at least I was able to confirm that it will fetch DEKs in batches which helps in better performance.
Hope this information helps others.