Skip to content

Conversation

phil1995
Copy link
Collaborator

In detail, two optimizations were made:

  • cacheMetadata(itemMetadataList:) now uses a UPSERT instead of a manual fetch and subsequent match.

  • flagAllItemsAsMaybeOutdated(withParentID:)now updates the entire request at once instead of iterating through each individual item.

Both optimizations take advantage of SQLite's standard features instead of using more inefficient "workarounds" in Swift.
Furthermore, both optimizations lead to a smaller memory footprint and are thus relevant for #232.

phil1995 added 2 commits July 15, 2022 09:27
by using `updateAll(_:onConflict:_:_:)` instead of looping through the resulting list
@phil1995 phil1995 requested a review from tobihagemann July 15, 2022 07:44
@tobihagemann
Copy link
Member

tobihagemann commented Jul 15, 2022

I wonder if the first optimization leads to significantly worse maintainability. Is the performance gain here really relevant? What do you think?

@phil1995
Copy link
Collaborator Author

I wonder if the first optimization leads to significantly worse maintainability. Is the performance gain here really relevant? What do you think?

I can understand the concern about maintainability.
However, I would argue that it is worth it in this case. On one hand, we already had to make sure that certain properties remain persisted during an update. On the other hand, we get at least a compiler error as soon as a column is no longer present, since these are referenced via ItemMetadata.Columns.columnName.
Also, this function is used on every successful call to enumerateItems(for:startingAt:) and especially for folders with many items, we should shorten the loading time as much as possible for the user. For example, for completely new folders, this halves the number of requests executed against the database.

@phil1995 phil1995 merged commit 1ca83ff into develop Jul 18, 2022
@phil1995 phil1995 deleted the feature/item-metadata-manager-db-improvements branch July 18, 2022 08:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants