Org roam can be slow at certain numbers of nodes - but it's possible to speed up with some helper funcs and attention to your roam-dir.
In my case, I had tons of "old" org files and archived things that were blowing up the `n` in my orders of magnitude.
my org-roam dir and file exclude regexp:
(setq org-roam-file-exclude-regexp
;; this is actually compared to a relative path,
;; despite org-attach-id-dir not being one - not sure how that works
(list org-attach-id-dir
"old/"
;; (file-truename "~/todo/old/")
;; (expand-file-name "~/todo/old/")
))
instead of including all the nodes in your find-file/insert-node lookups, you can filter things out.
Here are examples that lookup only top-level (file)
notes, and filter our
"/old/"
paths.
> Note that this is unnecessary if you're already
excluding it in
org-roam-file-exclude-regexp
.
(defun russ/org-roam-old-p (node)
"Returns true if the file is 'old', according to this function."
(or
(string-match-p "/old/" (org-roam-node-file node))
(member "reviewed" (org-roam-node-tags node))))
;;;###autoload
(defun russ/org-roam-insert-node-relevant ()
"`org-roam-node-insert' but filtering out misc old notes"
(interactive)
(let ((completion-ignore-case t))
(org-roam-node-insert
(lambda (node)
(not (russ/org-roam-old-p node))))))
;;;###autoload
(defun russ/org-roam-insert-file ()
"`org-roam-node-insert' but filtering for level 0 (files)"
(interactive)
(let ((completion-ignore-case t))
(org-roam-node-insert
(lambda (node)
(= 0 (org-roam-node-level node))))))
;;;###autoload
(defun russ/org-roam-find-node-relevant ()
"`org-roam-node-insert' but filtering out misc old notes"
(interactive)
(let ((completion-ignore-case t))
(org-roam-node-find
nil nil
(lambda (node)
(not (russ/org-roam-old-p node))))))
;;;###autoload
(defun russ/org-roam-find-file ()
"`org-roam-node-insert' but filtering out misc old notes"
(interactive)
(let ((completion-ignore-case t))
(org-roam-node-find
nil nil (lambda (node)
(= 0 (org-roam-node-level node))))))