Adding index on _partition field

hey,

I want to make an index on the _partition field. I have Realm-Sync in use (ios and android) and a WebApp (realm-web). I always deploy changes via the realm-cli.

Now if I want to make an index on the _partition field, can someone explain me where and how I have to make the change? In the schema itself? Or also in the ios / android apps?

Thx

Howdy!

You’ll want to define a { _partition: 1 } index for synced collections in your linked MongoDB Atlas cluster. These indexes (one for each collection) will help speed up the under-the-hood queries that Realm runs when it maps documents in MongoDB to synced realms in your mobile apps. They might also speed up queries from your web app that include the _partition field.

There’s a bunch of ways you can define the index:

You can create indexes for your mobile app’s local Realm Database, but not for the sync partition key (i.e. _partition). The field isn’t actually included in your mobile app’s synced object models so you won’t be able to index it locally. That’s fine though because the partitioning work all happens on the server side in Realm’s MongoDB queries.

3 Likes

Thank you for your explanations!

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.