Skip to content

Admin UI: reconstructing past snapshot of a collection is inefficient #1002

@leplatrem

Description

@leplatrem

In kinto.js, to build snapshot of collection at timestamp T we do:

  1. check that the history is complete (the collection creation entry is available)
  2. fetch the whole history of records changes for the collection
  3. start from the collection creation
  4. apply all history steps until timestamp=T

Source

This is inefficient, especially for old collections, mainly because we often want to compute a snapshot of a recent timestamp.

Why do we do this? Because the history entries contain the current version of the object, not the previous. Therefore entries related to deletion contain tombstones and not the deleted object. In order to obtain the deleted object attributes, we have to get its last update or its creation.

There should be more efficient ways.

For example, we could introduce a new endpoint and do it server-side where queries on the database are more efficient.

Or, find a smarter algorithm on the client, for example:

  1. fetch the collection content since timestamp=T. This will give us the list of records that were either created or changed or deleted since T.
  2. fetch the history entries related to these record ids where action is create or update, prior to timestamp<T
  3. use the most recent one of each entry to get the record attributes before it was deleted or modified

If the list of objects at step 1 is too big, then use the previous method.
In most cases, there should be less than a few dozens of records to inspect, because collections that contains many records are not manipulated by humans, and users won't compare with very old timestamps where a lot of records were modified.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions