Interesting, thx for the numbers. The issue for me (and this is just my opinion) is that clearing the search is very much a part of the "99%" a user does in Calibre. Whereas in normal usage, they are far less frequently changing their sort column order.
Had this change allowed the cleared search to remain the same, speeded up small sorts but slowed down sorts of large search results then it would be brilliant
Clearly there is a conflict.
I can't help wondering if "despite the dragons" we are instead not better off just trying to find another way to optimise for the type of behaviour I need for duplicate finder, that won't compromise general speed in Calibre today. For instance my idea of using sort history. I know you gave an example where the view contains added books - in this instance that is perfectly fine because I am refreshing the search and those books should disappear when that happens? And even if they didn't, letting them reamain at the top by not "re-sorting" is fine too?