Secondary views are always derived from the primary view. They can be deleted and recreated from the primary view at any time. Thus we should not be saving rows for secondary views to recovery files. Instead, we should only save the primary view and generate secondary view rows accordingly.

There are a couple of advantages to this:

  1. Insert performance will no longer depend on the number of secondary views.
  2. We can implement full-text searching on top of normal view mechanics. An inverted index will generate hundreds of rows for each update. Without this change, we would not be able to save those rows to a recovery file at insert time. With this change we can generate the row updates in memory. We can even generate the new rows asynchronously, as long as we complete the update before the next db flush.

Unit Tests

Before making this change we should create some simple unit tests for recovering a table. For example, we can add commands to drop the in-memory updates and recover from recovery file, and then test the database integrity (we would do this on a test table).