Any change to a photo recreates unchanged catalog-index database rows, and the sync-status queries rescan the whole table
- 1 reply
- 16 views
- Translate
Description of Issue
- Any change to a photo (rating, flag, edit, finished download, sync, etc.) makes Lightroom do far more work in its catalog index (Managed Catalog.wfindex) than needed, wasting system performance. These connected problems add up:
- Rows are deleted and inserted again instead of updated. For any change, the photo's rows in every index table are deleted and re-inserted, even when they come out identical: in asset_sync_status_ui (4 rows per photo), a rating change rewrote them twice, with the same values. A row that changes could be updated in place, and one that doesn't change needn't be written at all.
- Changes are reported for the whole table. Each rewrite counts as a change to the table, so every query registered on it runs again (after its calm window, 0-3s) and recomputes its answer for the whole library, instead of adjusting it from the rows that changed.
- Indexes are missing. Four of those queries (WFCatSyncStatus.lua) have no index that fits their filters. The only index starting with keepLocallyConfiguration is (keepLocallyConfiguration, assetId), and with 4 rows per asset the rows a query needs are spread over all 7,004 pages. These connections use SQLite's default 2,000-page cache, so each run reads about 36,000 pages from the file and takes 80–110ms.
- Write amplification: one rating change rewrote 32 index rows per photo, across 6 tables (1,553 rows for 48 photos).
- Why it matters: together they turn any change to any photo into several full-table scans, and a stream of changes keeps the scans running back to back, burning CPU time, I/O, and battery life that other tasks in Lightroom (or other apps) needs. Changing 48 photos in 2 minutes cost 36.9s of query time on the index connections (2.1s without the changes) and 2.7 million page reads (11 GB). Lightroom's disk writes went from 33 MB to 73 MB.
- Measured triggers:
- Ratings, the easiest change to make and undo (Lr v10.0): changing 48 photos in 2 minutes, the four queries ran 43–92 times each, and index reads went from about 900 to 22,000 per second.
- Downloads (Lr v9.6): while culling, Detail view downloaded each photo's original (report 3: https://community.adobe.com/questions-680/culling-in-detail-view-downloads-each-full-original-raw-instead-of-using-local-previews-1653952), and each finished download changed the photo's document. The index was read 37,700 times per second, the whole table about once a second on each of two connections. Lr v10.0 appears to no longer download them the same.
- Editing (Lr v10.0): 45 minutes of editing read 98 GB, mostly from this file (not broken down by query).
- Possible fixes, one for each problem:
- Update rows in place, and only the rows that change; when nothing changed, write nothing and report no change.
- Keep these summaries up to date from the rows that changed, instead of recomputing them from the whole table.
- Add an index the queries can use. Tested on a copy of the index: with (keepLocallyConfiguration, prioritizedSyncStatus, syncStatuses, isSearchable, docId, assetId, volumeGuidUsedByOriginal, volumeGuidUsedByProxy, spaceId), each of the four queries takes at most 7ms after its first run (10ms with that run's page reads), with no page reads after it, a time savings of >90%.
- Related: report 1 (https://community.adobe.com/questions-680/p-rendition-cache-purge-worker-loops-continuously-while-idle-deleting-nothing-1652164) covers the idle reads of the same file by the rendition cache purge worker.
Step-by-step Reproduction Instructions
-
Open Lightroom with a large library (here about 41,500 photos, all with proxies stored locally; 52,557 assets in the catalog index, counting stacks and deleted photos). Ensure Photo > Auto Advance is off. Open an album of unrated photos, select the first photo and press D for Detail view.
-
Generate a diagnostic log: Lightroom > Preferences (⌘,) > Account, hold Option, click Diagnostic Log (recommended), then Generate Log. Lightroom writes it to ~/Library/Containers/com.adobe.mas.lightroomCC/Data/tmp/DiagnosticLog(-N).html
-
In Terminal, list the catalog index's file descriptors, then count reads on each for 60 seconds while doing step 4:
lsof -p $(pgrep -x "Adobe Lightroom") | grep "Managed Catalog.wfindex$"
sudo fs_usage -w -f filesys -t 60 "Adobe Lightroom" | awk '/pread/ { for (i = 1; i <= NF; i++) if ($i ~ /^F=/) print $i }' | sort | uniq -c | sort -rn | head -5At this rate fs_usage may report lost events, so the counts are a lower bound.
-
In Lightroom, change photos one after another for that minute. Any change works; a rating is the easiest to make and undo: press 1, then 0, then → to move to the next photo, one key press per second.
-
Generate a second diagnostic log as in step 2. In each log, find the tables headed "QUERY PROFILE SUMMARY FOR DATABASE …/Managed Catalog.wfindex" (one per connection) and compare the Count of the queries on asset_sync_status_ui. The rewrites show up as "COMMIT :: queries were: DELETE FROM asset_sync_status_ui WHERE docId == ? …" and "INSERT INTO asset_sync_status_ui VALUES( ?, ?, ?, ?, ?, ?, ?, ?, ? )".
-
For comparison, repeat steps 2–5 pressing only → to move to the next photo, without changing anything.
-
To see one query's cost and the effect of an index, quit Lightroom, copy the index, and open the copy with macOS's sqlite3 (the copy is only changed in /tmp):
cd ~/Pictures/"Lightroom Library.lrlibrary"/*/
cp -c "Managed Catalog.wfindex" /tmp/index.wfindex
[ -f "Managed Catalog.wfindex-wal" ] && cp -c "Managed Catalog.wfindex-wal" /tmp/index.wfindex-wal
sqlite3 /tmp/index.wfindexThen run one of WFCatSyncStatus's queries twice, add an index, and run it twice more. After each run,
.stats onprints "Page cache misses" (page reads from the file) and.timer onthe time:.stats on
.timer on
SELECT DISTINCT prioritizedSyncStatus, volumeGuidUsedByOriginal, volumeGuidUsedByProxy, spaceId FROM asset_sync_status_ui WHERE keepLocallyConfiguration == 0 AND prioritizedSyncStatus IN ( 64, 128, 67108864, 134217728, 1 );
SELECT DISTINCT prioritizedSyncStatus, volumeGuidUsedByOriginal, volumeGuidUsedByProxy, spaceId FROM asset_sync_status_ui WHERE keepLocallyConfiguration == 0 AND prioritizedSyncStatus IN ( 64, 128, 67108864, 134217728, 1 );
CREATE INDEX test_b ON asset_sync_status_ui( keepLocallyConfiguration, prioritizedSyncStatus, syncStatuses, isSearchable, docId, assetId, volumeGuidUsedByOriginal, volumeGuidUsedByProxy, spaceId );
SELECT DISTINCT prioritizedSyncStatus, volumeGuidUsedByOriginal, volumeGuidUsedByProxy, spaceId FROM asset_sync_status_ui WHERE keepLocallyConfiguration == 0 AND prioritizedSyncStatus IN ( 64, 128, 67108864, 134217728, 1 );
SELECT DISTINCT prioritizedSyncStatus, volumeGuidUsedByOriginal, volumeGuidUsedByProxy, spaceId FROM asset_sync_status_ui WHERE keepLocallyConfiguration == 0 AND prioritizedSyncStatus IN ( 64, 128, 67108864, 134217728, 1 );
The Expected Result
- A change to one photo updates only the index rows that change, in place, and writes nothing to a table whose rows didn't change.
- Queries that summarize the whole library aren't recomputed from scratch after each changed row.
- The sync-status queries use an index: they take a few milliseconds and their pages stay in the cache.
- A stream of changes, such as rating or flagging photos while culling, doesn't make Lightroom read its catalog index tens of thousands of times per second.
The Actual Result
- Steps 3–5, Lightroom 10.0, 2026-11-23 00:20: 48 photos in 2 minutes, each rated 1 star and back to none, about one every 2.5 seconds:
- Index reads: 489,414, 766,050, 591,371 and 839,554 per 30s (22,454 per second on average). Step 6 without ratings: 26,690–26,989 per 30s (895 per second, still crazy high).
- Lightroom's query statistics between the two diagnostic logs, 2.6 minutes apart:
- SELECT DISTINCT prioritizedSyncStatus, volumeGuidUsedByOriginal, volumeGuidUsedByProxy, spaceId … IN (…): 76 runs, 83ms each.
- SELECT prioritizedSyncStatus … WHERE isSearchable == 1 … IN (…) LIMIT 1: 75 runs, 80ms each.
- SELECT DISTINCT albumId FROM album_asset_v2 WHERE assetId IN ( SELECT assetId FROM asset_sync_status_ui … syncStatuses & ? ): 43 runs, 87ms each.
- SELECT prioritizedSyncStatus … LEFT JOIN space … LIMIT 1: 92 runs, 20ms each.
- The whole index: 17,282 statements, 36.9s. Without ratings (step 6): 615 statements, 2.1s, and each full-table query on asset_sync_status_ui ran once.
- Cost, same 2 minutes: 2.7 million page reads of the index (11 GB). Lightroom's physical disk reads were 0.87 GB, against 1.20 GB in step 6, so the page reads came from the OS' file cache. Lightroom's disk writes, all files: 73 MB physical and 111 MB logical, against 33 MB and 39 MB in step 6.
- Copies of the catalog and the index taken before and after: 49 photo documents got one new revision each with the same rating (only the rating date, changedAtTime and userUpdated changed). Each photo's 4 asset_sync_status_ui rows had been deleted and inserted twice and ended with identical values: 384 rows inserted for 48 photos. The photos' rows in other index tables were rewritten too: purgeCandidates 547 rows, localAuxTracker 299, auxReferenceTracker 270.
- Step 7, on a copy of 10.0's index (4 × 52,557 rows, 7,004 pages):
- Each of the four queries reads about 36,000 pages and takes 83–108ms, the second run as much as the first.
- With a cache that holds the table: no page reads after the first run, reducing query time to 48–70ms.
- With index test_b (6,577 pages): at most 7ms and no page reads after the first run, which takes up to 10ms.
- Other changes, same file:
- Lightroom 9.6, 2026-11-02, 90s of culling in Detail view while it downloaded each original: 3,407,797 index reads (37,705 per second). A System Trace of culling showed passes over the whole table of about 39,000 page reads each, 1.3s apart on each of two connections.
- Lightroom 10.0, 2026-11-15, 45 minutes of editing: Lightroom read 98 GB in all, mostly from Managed Catalog.wfindex.
- How the rescans are triggered, from 10.0's Lua (the attachment has the details):
- The index definition of asset_sync_status_ui in WFCatSyncStatus.lua has relevantTypeSubtypeTuples = { 'asset', '*' } and hasOneRowPerDocument = false.
- Registered queries rerun after each update of a table they read (watchForTableUpdatesForSql in WFRxIndexStoreImpUtils.lua), through the caller's calm window or else a 0.125s debounce.
- The four queries above set calm to 1s, 3s, or nothing.
System Details
- Lightroom 10.0 (Mac App Store), build 2026.1029.0836, arm64; also seen on 9.6, build 20260923-1659-a32d844
- macOS 27.2.1 (26B131), MacBook Pro 16" (MacBookPro18,2), Apple M1 Max (10 cores), 64 GB RAM
- Cameras: Canon R5m2 and R6m3, shooting in cRAW
- Library: about 41,500 photos (52,557 assets in the catalog index); all proxies stored locally
