It’s probably a stupid question, but it keeps coming back to me. Can you have some conditional word like OR or AND in between FROM and WHERE in dataview query? For example, list all files from a specific folder or with a specific character in a file.name.
FROM is the best place to optimise your query but it’s reasonably restrictive. you’d have to keep the folder filter in your FROM, and your conditional part in your WHERE. if the folder doesn’t have a ton of files in it it’ll still be fast, but you may find benefits to using AND #sometag if the folder gets too stuffed
OK. Thanks. But you gave me an idea. I don’t know why I didn’t think of it earlier. If I really wanted to do it - it must be something like this, right? Or maybe with file.path. It seems to work fine for my contacts that were accidentally put inside wrong folders.
table without id file.link as Note
where icontains(file.folder,"Contacts") or icontains(file.name,"@")
sort file.name ASC
if this is fast enough for you then job done! but if it gets slow you will want to use FROM as well as WHERE. Basically any way you can filter down to a smaller set of files with FROM will speed up your query
Ok. Understood. It’s because I didn’t start to add “@” to the contact file names from the beginning, but now I want a full list. When I finally tidy it up, even just one condition should be enough. Thanks again
Another way to look it is to consider what’s the scope of which files you’re looking at. When using FROM you limit from looking at all files to all smaller subset of files. i.e. FROM "this/folder" you’ll only look at the files from that given folder.
Using WHERE looks at all files from the current scope of files. So no FROM means you’re looking at all the files from your entire vault, but with a FROM it only looks at that subset of files.
Either of these can use both AND and OR, but you can’t combine and say FROM "this/folder" OR WHERE file.folder="another/folder". This will cause an error. You should however be able to say FROM "this/folder" OR "another/folder".
So if you’ve got a smaller vault, there is not really a need to use FROM unless it’s very logical to use it, as the number of files aren’t that large anyways. But given a larger vault, your queries can greatly benefit from including and/or excluding specific folders since that could drastically reduce the numbers of files in the file set that the WHERE clauses needs to work with in the second part of your query.
An illustration of the above point. Given a vault with a 100 000 files divided into 10 folders each having 10 sub-folders so that each of these folders are having 1000 files. If you could use FROM "folder/sub-folder" your query would only look at 1000 files, instead of the full 100 000 files.
My volt isn’t that big yet. The problem is that I can be pretty messy. I always forget my own sorting systems. So for me, it is a measure of control. I’ve set up a bunch of indexes for different types of notes, with as wide a query as possible, so I could find all notes in their rightful folders and also misplaced ones. And then tidy up I took the idea of “marking” different types of notes with special character, I think FromSergio, (great youtuber), who advocates not having any catalogs at all. But I guess I’m not brave enough. And while sticking up to the old ways of sorting most of my mess into folders, both your answers about speed will be very helpful, especially in time. Thanks