(perf)db: wrap update-file in sql transaction (#1827)

This should lead to some performance gains on buffers with lots of
inserts required (e.g. when the buffer has a lot of links).
This commit is contained in:
Jethro Kuan
2021-09-01 19:43:19 +08:00
committed by GitHub
parent a8a36a420b
commit 1795039ab9
2 changed files with 21 additions and 19 deletions

View File

@ -8,6 +8,7 @@
### Changed ### Changed
- [#1795](https://github.com/org-roam/org-roam/pull/1795) buffer: optimized reflinks fetch - [#1795](https://github.com/org-roam/org-roam/pull/1795) buffer: optimized reflinks fetch
- [#1809](https://github.com/org-roam/org-roam/pull/1809) capture: the mandatory `:if-new` property of each capture template is now renamed to `:target` - [#1809](https://github.com/org-roam/org-roam/pull/1809) capture: the mandatory `:if-new` property of each capture template is now renamed to `:target`
- [#1829](https://github.com/org-roam/org-roam/pull/1829) perf: file sql updates are now wrapped in a transaction
### Fixed ### Fixed
- [#1798](https://github.com/org-roam/org-roam/pull/1798) org-roam-node-at-point: do not skip invisible headings - [#1798](https://github.com/org-roam/org-roam/pull/1798) org-roam-node-at-point: do not skip invisible headings

View File

@ -495,26 +495,27 @@ If the file exists, update the cache with information."
info) info)
(unless (string= content-hash db-hash) (unless (string= content-hash db-hash)
(org-roam-with-file file-path nil (org-roam-with-file file-path nil
(save-excursion (emacsql-with-transaction (org-roam-db)
(org-set-regexps-and-options 'tags-only) (save-excursion
(org-roam-db-clear-file) (org-set-regexps-and-options 'tags-only)
(org-roam-db-insert-file) (org-roam-db-clear-file)
(org-roam-db-insert-file-node) (org-roam-db-insert-file)
(setq org-outline-path-cache nil) (org-roam-db-insert-file-node)
(org-roam-db-map-nodes (setq org-outline-path-cache nil)
(list #'org-roam-db-insert-node-data (org-roam-db-map-nodes
#'org-roam-db-insert-aliases (list #'org-roam-db-insert-node-data
#'org-roam-db-insert-tags #'org-roam-db-insert-aliases
#'org-roam-db-insert-refs)) #'org-roam-db-insert-tags
(setq org-outline-path-cache nil) #'org-roam-db-insert-refs))
(setq info (org-element-parse-buffer)) (setq org-outline-path-cache nil)
(org-roam-db-map-links (setq info (org-element-parse-buffer))
info (org-roam-db-map-links
(list #'org-roam-db-insert-link))
(when (require 'org-cite nil 'noerror)
(org-roam-db-map-citations
info info
(list #'org-roam-db-insert-citation)))))))) (list #'org-roam-db-insert-link))
(when (require 'org-cite nil 'noerror)
(org-roam-db-map-citations
info
(list #'org-roam-db-insert-citation)))))))))
;;;###autoload ;;;###autoload
(defun org-roam-db-sync (&optional force) (defun org-roam-db-sync (&optional force)