DOCS-1105 sort w limit and other optimization