It seems that when you want to find all the notes for the certain tag from the Tag pane, or directly search via tag: #mytag in the search pane, it does a full-text search, which is extremely slow for large vaults because Obsidian doesn’t have a built-in full-text search index. However, tags are part of the metadata and are being cached, so they can be found much efficiently.
Add a special logic to the search functions to look for tags efficiently from cache.
Ideally, Obsidian team to consider adding a full-text search index for all notes, not just metadata.
Current workaround (optional)
Omnisearch plugin adds full-text search index so you look for tags in it, but it is not perfect because it gives false positive results.
Searching that way is definitely intended to search the index. Have you compared the speed of that search to a plain text search for #mytag (without the tag: )? to check if they both run at the same speed? The plain text search should be slower.
EDIT: I just tried it myself and the “tag:” search, which I did first, was actually slower. The plain text search was fast. Subsequent “tag:” searches and plain text searches were both quite fast. I wonder if the slowness is from something being loaded when you haven’t searched in a while. I tested on an iPad; then on Mac I tried plain text first and it was slower by a bit and all subsequent searches were faster.
My vault is huge (40k notes), plaintext search is unusable for me, that’s why I am trying to take advantage of cache everywhere where it is possible.
If I run app.metadataCache.getTags() from the Developer Console, it’s instant, and as I see the implementation, it traverses the entire cache, which I guess could be improved even further, but it is already super fast.
Search by tag: #tag is not even close to that speed, it takes minutes for me