speed up org-roam-db-sync by wrapping db activity in a transaction (#1495)

In my case of testing with 8253 zettels (available on request if
anyone wants to test with them), this improves cleanup speed by 6x
and update speed by 2x.

Improvements will be smaller for smaller batches as this really just
removes the transaction overhead.
This commit is contained in:
Bill Burdick
2021-04-30 00:51:29 -04:00
committed by GitHub
parent 389bf3c7e2
commit 0a7d365e22

View File

@@ -435,6 +435,7 @@ If FORCE, force a rebuild of the cache from scratch."
contents-hash)
(push file modified-files)))
(remhash file current-files))
(emacsql-with-transaction (org-roam-db)
(if (fboundp 'dolist-with-progress-reporter)
(dolist-with-progress-reporter (file (hash-table-keys current-files))
"Clearing removed files..."
@@ -446,7 +447,7 @@ If FORCE, force a rebuild of the cache from scratch."
"Processing modified files..."
(org-roam-db-update-file file))
(dolist (file modified-files)
(org-roam-db-update-file file)))))
(org-roam-db-update-file file))))))
(defun org-roam-db-update-file (&optional file-path)
"Update Org-roam cache for FILE-PATH.