<div>Hi Chris,</div><div><br></div><div>now I see how it works. And why I needed to develop that extra part of code to make it work in my case. Let me try to explain a bit further why. </div><div><br></div><div>The PagedReader class I&#39;m developing to visualize data in the GUI requires some subclass with following protocol:</div>
<div>PRPagedReaderSource&gt;&gt;readFrom: elementStartIndex to: elementEndIndex</div><div>PRPagedReaderSource&gt;&gt;refresh</div><div>PRPagedReaderSource&gt;&gt;totalNumberOfElements</div><div><br></div><div>Using an implementation of this, you can page your data up, calculate how many pages there are, navigate to next / prev pages, and forth.</div>
<div><br></div><div>I&#39;ve created an implementation for MagmaCollectionReader. But since this can be any MagmaCollectionReader; I had to take into account that the MagmaCollectionReader might still not be sorted yet.</div>
<div><br></div><div>The method for instance I was using for testing this, was:</div><div>BMTMagmaTodoRepository&gt;&gt;findTodosWithTitle: aString<br>   ^PRPagedReader on:<br>            ((items<br>                      where: [:eachTodo|        eachTodo title match: aString]<br>
                      distinct: false<br>                      sortBy: #dueDate<br>                      descending: false) <br>             asPagedReaderSource)</div><div><br></div><div>So I have a where clause on one attribute, but are sorting on another one; so magma needs to do a background sort; leading to the implementation of above to make the total number of items work. I first used sortedBy: but that took around 15 seconds to do a sort of a test set of 7000 items, which off course was too long. I only needed to show the first 20 of them quickly, and in the background the server was sorting the rest for me.</div>
<div><br></div><div>Since I want to keep my abstraction of PagedReader to work on any MagmaCollectionReader (and let the repository - BMTMagmaTodoRepository - business logic do the sort) - so in fact separate both concerns; I had to implement it this way.</div>
<div><br></div><div>The remark you make about doing the where: clause first, taking the size, and then doing the sort is true; but only if you&#39;re not requiring distinct results.</div><div><br></div><div>I still have one further question about this. If the #fractionSorted for instance replies with: (2249/6065); does this then mean for sure that the GUI visualizing the query can show the first 2249 items correctly sorted ? I mean, if I for instance show items 1-20, there will come no other items 1-20 even if the sort is not done yet ? That the sort up to item 2249 is already correct? (This would be a very good thing) Or does this mean that just 2249/6065 percent of the result is sorted? (This would make it a rather bad thing?).</div>
<div><br></div><div>What I also noticed that if the server is doing this background sort, and I am already asking the next page; that there is something wrong with the priorities of both. What I would find reasonable is that the background sort should get a lower priority than me asking the next page. So that this next page is returned quickly, and the background sort due to its lower priority is kinda &#39;paused&#39; for this short time. But I&#39;m not sure if this does make any sense.</div>
<div><br></div><div>Thanks again for your support.</div><div><br></div><div>Kind Regards,</div><div><br></div><div>Bart</div><div><br></div>