(perf): Deprecate link :outline properties

As it happens, turning sexps into strings is one of the
computationally expensive steps in EmacSQL.

With an enormous number of links in the database, that's a lot
of (:outline nil) to stringify into "(:outline nil)".

Its only use was in org-roam-node-insert-section,
where the information is very cheap to reconstruct.
It's already in one of the other arguments!

This has passed unnoticed because org-roam-db-sync has other
performance tarpits, but it will probably be noticed eventually after
those get fixed.
This commit is contained in:
Martin Edström
2025-03-12 23:47:17 +01:00
committed by Dustin Farris
parent 0037daaf3e
commit db4170a459
2 changed files with 11 additions and 16 deletions

View File

@ -108,7 +108,7 @@ ROAM_REFS."
:type '(alist))
;;; Variables
(defconst org-roam-db-version 18)
(defconst org-roam-db-version 19)
(defvar org-roam-db--connection (make-hash-table :test #'equal)
"Database connection to Org-roam database.")
@ -214,7 +214,7 @@ The query is expected to be able to fail, in this situation, run HANDLER."
(source :not-null)
(dest :not-null)
(type :not-null)
(properties :not-null)]
properties]
(:foreign-key [source] :references nodes [id] :on-delete :cascade)))))
(defconst org-roam-db--table-indices
@ -507,11 +507,8 @@ INFO is the org-element parsed buffer."
(path (if (not option) path
(substring path 0 (match-beginning 0))))
(source (org-roam-id-at-point))
(properties (list :outline (ignore-errors
;; This can error if link is not under any headline
(org-get-outline-path 'with-self 'use-cache))))
(properties (if option (plist-put properties :search-option option)
properties)))
(properties (when option
(list :search-option option))))
;; For Org-ref links, we need to split the path into the cite keys
(when (and source path)
(if (and (boundp 'org-ref-cite-types)
@ -533,9 +530,7 @@ INFO is the org-element parsed buffer."
(goto-char (org-element-property :begin citation))
(let ((key (org-element-property :key citation))
(source (org-roam-id-at-point))
(properties (list :outline (ignore-errors
;; This can error if link is not under any headline
(org-get-outline-path 'with-self 'use-cache)))))
(properties nil))
(when (and source key)
(org-roam-db-query
[:insert :into citations