Reduce unnecessary Mongo polling in more cases.

Specifically, we can now detect if a selector matches at most a fixed set of
IDs (instead of just "at most one ID"), both for queries and for writes. This
includes every write made from the client on a restricted collection!
Improve id-invalidation test to explicitly be about "how many times did polling
happen?" rather than "how many things changed"?