Initializing org-roam database... taking a long time

I have around 400 org files that I have been adding to my org-roam zettelkasten. I launch Doom Emacs in less than a second but the first time I load an org file in the org-roam db I get this message.

Initializing org-roam database…

and I have to wait for about 10 seconds.

Is this the expected performance or there is something wrong going on here?

Sounds normal to me. The next time you use Org-roam, it should be much quicker. Once database is built, it only looks at the changed files.

If you get initialization every time you add a new file, that sounds odd.

yeah I get that message every time I launch emacs for the first time.

I don’t think that’s normal.

You should rather see something like this: “Processing modified files…done”.

Review your config. You might like to consult the Doom community. There are also a number of people here who use Doom, so maybe they can jump in. I don’t use it.

Were your org files modified? It could be they were touched by other processes (e.g. when under version control).

Same issue here. I sync my repos with Git regularly, so I wouldn’t be surprised if Git is touching a lot of these files. To try to work around this, after I complete my Git sync, I’m going to try to run git-restore-mtime to restore the mod times of the files to the time they were modified in Git. I’ll see whether that helps.

Org-roam with vanilla Emacs, there is no message “Initializing org-roam database…”
It’s coming from Doom’s specific code for the +roam2 flag in this line.

The Git issue @bram85 and @telotortium are discussing might still be the cause; but one possible direction may be looking at the Doom’s code around that message. You can probably test it easily with Doom’s sandbox without using +roam2 (?)

I don’t sync my notes with Git so I can be wrong about this. Just an observation.

It looks like Doom does run org-roam-db-sync the first time Roam is used after startup, but I think org-roam-db-sync should return fairly quickly if a file hasn’t been modified (which is done via hashing the file, so shouldn’t be affected by the mtime). However, it appears that reverting a file calls some hook in org-roam, which might conceivably cause a slowdown.

Alright, I tried again without having the files under git and everything is significantly faster. I still see the message “Initializing org-roam database…” but for 500ms or so. So is git the culprit? Is telotortium solution the way to go?

I have the same problem with Spacemacs, my note repository is on Dropbox. Every time I start Emacs it takes ages for all my 500+ notes to be reprocessed as “modified” (they’re not)…

Is there any news on this subject? In the meanwhile I have tried moving my notes from Dropbox to a local folder: the constant re-processing of files doesn’t happen in this case. It must therefore be something caused by Dropbox: could it be touching files unrequestedly?

I started using Dropbox with Org-roam on Windows. I don’t use Doom. No Git, either. I don’t experience any delay.

It might be worth asking the Doom community?

Well, I forgot to tell that I don’t use Doom but Spacemacs on Macos: so the problem doesn’t seem Doom-specific. Also, as I said, when I use a local folder there is no problem at all… Thank you so much for your help, btw!

I see. The original issue was for Doom and Git.
Your issue is Spacemacs and Dropbox.

We do not know if we are talking of a single same issue, or two different ones.

You may be experiencing a Spacemacs-specific issue with Dropbox then.
I suggest you ask the Spacemacs community.

Did any of you solve this? I have the same issues, every time the db syncs it clears removed files and then “Processing modified files…” taking about 15 minutes to complete (~3800 files). I’m in a Dropbox synced folder and I have a git repository.

Seems like it rebuilds the entire database all the time and not just updating modified files. This happens even if I haven’t created a new file or changed any links…