Search code examples
xpagesssjs

Sorting of document collection with compromising performance in SSJS


I want to sort notesDocument collection based on any key or date in ascending order ( document creation date). Actually I need data to display in data table in descending order so that user can view most recent record on the top.

Please provide me solution to sort the collection but I don't want to compromise the performance.

Thanks, Qaiser


Solution

  • Qaiser, if you want to avoid a performance hit, don't use database.search. It is the equivalent of a full table scan without an index. Bad idea.

    The better way: create a view that has all the columns you need and is sorted the way you need it. So your first column would be the field with the user name, categorize it, then a column with the date, sorted.

    Then you can use a ViewNavigator which is the fastest construct in Domino.