[Question] Are filter operator order affects performance?

51 views
Skip to first unread message

Tony K

unread,
May 16, 2020, 6:56:42 AM5/16/20
to TiddlyWiki
Wondering about scalability and performance of filters

these 2 will yield the same results howevr my question is does it affect performance?

from a logic standpoint 

This one should evaluate the is[current] first and then apply the regex

<$list filter="[is[current]regexp:keywords[Wiki]]"/>


and this one should get all Tiddlers with Wiki in the keywords and then filter only the current 
<$list filter="[regexp:keywords[Wiki]is[current]]" />

So, my logic again, the first one is the correct way to go

It that true in TW5?
'
thank you 

Mat

unread,
May 16, 2020, 7:28:23 AM5/16/20
to TiddlyWiki
I think your question is answered in the following thread which should be of overall interest for you:

PMario

unread,
May 16, 2020, 7:50:58 AM5/16/20
to TiddlyWiki
Hi Tony,

I think you know the answer.

 - [is[current]] internally reads the <<currentTiddler>> variable and compares it with the "inputed list" ... If there is no input it uses every tiddler.
 - [regexp:keywords[Wiki]] will search all tiddlers from the input list if the "search word" is part of the field.

The regexp search is heavier than searching the list of all tiddlers, especially if you search the "text field".

So if you do a regexp search in 1 tiddler will need less time if you do a regexp search in every tiddler and then look if the current tiddler is part of the list.

-------------------

But this:
- [all[current]regexp:keywords[Wiki]]  does the same thing is much faster.

[all[current]] doesn't search the input list. It internally reads the currentTiddler variable and returns it. done.

[is[current]] can be negated, [all[current]] can't.

Tony K

unread,
May 16, 2020, 7:58:37 AM5/16/20
to TiddlyWiki
Thank you Mat very interesting indeed

Tony K

unread,
May 16, 2020, 7:59:53 AM5/16/20
to TiddlyWiki
Thanks a lot PMario, I've been wondering about the difference between all[current] and is[current] I somehow thought that is[current] is faster but good to know the truth

Cheers

TonyM

unread,
May 16, 2020, 8:01:15 AM5/16/20
to TiddlyWiki
Tony k

I will add people who new what they were talking about insist [all[current]] is more efficient than [is[current]] which is opposite to what you would expect. They are the same.

On tiddlywiki.com there is also information about some common filters that are optimised with internal indexes.

I would go with what is most meaningful to you or a theoretical reader unless you plan a large wiki Or experience a performance problem.

Regards
Tony

PMario

unread,
May 16, 2020, 8:18:33 AM5/16/20
to TiddlyWiki
On Saturday, May 16, 2020 at 1:59:53 PM UTC+2, Tony K wrote:
Thanks a lot PMario, I've been wondering about the difference between all[current] and is[current] I somehow thought that is[current] is faster but good to know the truth

Yea,

[all[current]] ... The naming is a little bit misleading. Have a look at the code. It's really simple and fast.

[is[current]] looks different. see the code. The "source function" iterates over the input titles. And you can see the "!" prefix handling.

It's not necessary to understand everything, but I think the difference is visible.

-m
Reply all
Reply to author
Forward
0 new messages