Slow file loads - need help with more efficient Dataview queries

What I’m trying to do

I use my Obsidian vault for work and I like to create “dashboards” for each project I’m working. In that file, I use dataview queries to pull together tasks and other files where the project is tagged. I’m starting to notice that my file loads very slowly and I believe it’s because I have too many separate dataview queries and they are probably not written as efficiently as they can be. I have 1-2 queries inside callouts on the page to make it easier to navigate.

It all looks beautiful and clean, but the page takes 1-2 seconds to load and I don’t want to bog down my vault if I can do it better.

Things I have tried

I have tried using a single dataview query for things like Decisions/Risks, but I am unable to use GROUP BY on task status and maintain the table view, so I broke them into two separate queries.

Example

> [!todo]+ Open Tasks
>  ✅ **Open Tasks**
>  ```dataview
>  TASK
>  WHERE !completed AND contains(tags,this.file.etags[0])
> ```
> - [>] **Open Tasks - Not Owned by Me**
>  ```dataview
>  TABLE without ID
> 	 task.text as "Task",
> 	 file.link as "File Name",
> 	 dateformat(file.cday,"MM-dd-yyyy") as "Logged On",
> 	 dateformat(task.due,"MM-dd-yyyy") as "Target Date"
>  FLATTEN file.tasks as task
>  WHERE contains(">", task.status)
>  WHERE file.folder != this.file.folder AND contains(file.tags, this.file.etags[0])
>  ```

> [!summary]- Meeting Log
> ```dataview
> TABLE
> 	file.cday as Created,
> 	file.mtime as "Last Modified",
> 	type as Type
> WHERE file.folder != this.file.folder AND contains(file.tags, this.file.etags[0])
> SORT file.mtime DESC
> ```

> [!attention]- Decisions & Risks
> - [n] **Decisions** 
>  ```dataview
>  TABLE without ID
> 	 task.text as "Log Item",
> 	 file.link as "File Name",
> 	 created as "Logged On"
>  FLATTEN file.tasks as task
>  WHERE contains("n", task.status)
>  WHERE file.folder != this.file.folder AND contains(file.tags, this.file.etags[0])
>  ```
> - [!] **Risks**
>  ```dataview
>  TABLE without ID
> 	 task.text as "Log Item",
> 	 file.link as "File Name",
> 	 created as "Logged On"
>  FLATTEN file.tasks as task
>  WHERE contains("!", task.status)
>  WHERE file.folder != this.file.folder AND contains(file.tags, this.file.etags[0])
>  ```

again, i won’t be popular with a non-answer…

…but as long as the queries don’t feature in every single file you open, 1-2 secs are not that long…
secondly, you seem to only query what is already ready to be taken out from metadatacache, so it’s not really a dataview thing…
thirdly, dataview will be soon(?) replaced by (datacore? core databases?)…but that doesn’t concerns us now…

in comparison, my dashboard file has 10-15 queries where most of those (if not all?) query the entire vault’s content…and it’s still not that bad… i try not to look into it for a few days anyway…

1 Like

Actually, I don’t mind the “non-answer” because it somewhat validates that I’m not doing anything weird or crazy here. Now, I need to go look into the replacement for dataview because that is going to be an insane amount of work if I need to refactor my vault.

Thank you!

1 Like

i’m not too savvy on (the quirks of) dataview (so/and no idea how to refactor something working to someone else’s mindset) so all i really did was some kind of commiserating here :slight_smile:

i’m not really one for eye candy so don’t know if it’s not something to do with the embedding in callouts and your theme…
could be any number of things, actually…

One of the things you could try (assuming it works for your situation) is limit the directories that dataview has to look through. I find some “where” clauses (for dataview) and “path” (for tasks) makes a difference in the speed of my queries.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.