Filters can be defined for incoming queries with Realm. Realm evaluates and applies those filters before an initial query is made to your MongoDB cluster. Adding a filter to a collection can improve query performance by reducing the number of documents for which Realm needs to evaluate a role.
Roles are sets of document-level and field-level CRUD permissions. Realm chooses roles individually for each document associated with a query. Roles consist of rules which are defined for entire collections in a linked MongoDB Atlas cluster. They apply to individual documents in a collection dynamically, based on the application user that issued a query.
Because roles are applied to individual documents, they may impact performance if the number of examined documents is large. To reduce the number of results, we recommend you apply filters - which are applied before roles - whenever possible.