craiggwilson/fluent-mongo — Issue #30: OrderBy performance?
Author: Osypchuk
Created: 2011-10-15 21:22:42+00:00
State: open

I have troubles with orderby + paging combination. I have collection with 30000 items and have serious performance degradation:

model.Details = (from p in repository.GetAll()
where p.Type != ProductItemType.ProductVariant
orderby p.Title
select p).Skip(model.PageSize * (model.CurrentPage - 1)).Take(model.PageSize).ToArray();

Execution time of this request is 5 seconds.
When I comment out orderby p.Title, which is basic string property, execution time is 0.03 seconds.

Usage of .OrderBy() doesn't make any difference. Also, I call ensureIndex for Title column. I also check performance for sorting by other column of type int - execution time is same.

When I try to use sorting firectly from mongo it works relatively instant (I do not know how to measure exact time).

Thanks for help in advance