You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
A re-fetched message is rewritten and re-indexed even when nothing changed #87
A message that is fetched again is written again in full, and the messages_cache_au trigger deletes and re-inserts its search index row, even when nothing the index holds has changed. After every daemon restart or reconnect, catch-up fetches again the messages that arrived live (about one getHistory call per 100 of them per chat, see docs/sync-strategy.md), so each of them costs a row rewrite and an index update. Marking a message deleted re-indexes it too. The cost hasn't been measured.
idx_messages_cache_fetched (messages_cache(fetched_at)) has no query that reads it; it only takes space for every message.
Proposed:
The upsert skips the update when the stored row would not change apart from fetched_at and updated_at.
The update trigger fires only when a column that feeds the index changes (text, from_id, media_path). Existing caches get the new trigger on their first open.
Drop idx_messages_cache_fetched, after checking with EXPLAIN QUERY PLAN that no query uses it.
Done when tests show that re-fetching an unchanged message and marking one deleted leave the index alone, an edit still re-indexes it, an existing cache gets the new trigger and loses the index, and the docs describe it. Related: #80.
Activity
perf(cache): leave unchanged re-fetched messages and their index alone
perf(cache): drop the unused fetched_at index on messages_cache