Question: Is index stored on the mobile device


When creating an index on table in Journey (with the index keyword)…
is this index stored on the mobile device or on the Journey backend?

Just checking, because we are concerned about the amount of data stored on the mobile device.

Another question: is there a way perhaps to check the size of the data used by the index on Journey?

Hi @chansmann

The index data is stored on the user’s device.

Below we go through two approaches to obtaining an index’s data size:

In version 4.85.0 (currently beta), on the web container, the diagnostics page gives an estimate of the total size of indexes, as in the screenshot below. While it doesn’t show the size of individual indexes, you can see the effect when adding or removing an index. The size isn’t displayed on other containers (Android/iOS/desktop), but the size should be approximately the same.

Alternatively, you can estimate by adding up the sizes of indexed fields. For example, suppose the user model has an index on name . Then this code should give an estimate:

var indexSize = 0;
var users = DB.user.all().toArray(); // Add `await` for dev console or TS app.
for (var i = 0; i < users.length; i++) {
   indexSize += OBJECT_OVERHEAD + (users[i].name || '').length;

There may be additional overhead, and some characters my take up more than 1 byte, but it should give a rough estimate. For integer fields, use 4 bytes per field as an estimate, and 8 bytes for decimal fields.

Hi Willem

Thanks for your answer.

For the Web Container - it looks like there are two options: either using a test instance with the “Test app” → “test on web” buttons or contacting JourneyApps Support to arrange for a domain that points to a specific instance. I just want to confirm: can the web container be enabled for a specific instance only?

Because we have more than one model table that has an index, I am not sure that even the summary on the diagnostics page will help determining excessive data usage per table on the mobile device. So it probably means that we would have to use an estimation.

I have seen a post on the internet, though, where the suggestion was to turn the indexes on and off, and to look at the differences in reported size. This is something that could be applied to this case. However, it is difficult to do this on a production instance. It probably means that we would have to copy data over from a prod instance to a test instance to test.

Hi Willem

I had a thought: perhaps a way to estimate the index size would be to enable and disable the index and to look at the difference in total data size of the app on the mobile device?

Hi @chansmann ,

It will not be that easy to estimate the index size by disabling and enabling an index and then checking the total data size. The total data size will not change unless you re-enroll after you have updated an index.

With regards to the web container pointing to a specific instance: I am not sure you need a custom web container for what you are trying to achieve. The data you work with depends on the environment you enroll into. If you enroll using a user object from the Production database, you will be dealing with the production data in the app. So you should be able to check the production data using the “test on web” functionality.

Are you able to enroll into the Production environment of your app? In this case, it would not be necessary to copy data over to a different database.