0

I have more than 20000 documents in mongo and also added the index on date and version and I want to order it by these two fields

order_by('-date', '-version')

but while ordering it throws this error

database error: too much data for sort() with no index.  add an index or specify a smaller limit

Could you please help me out to resolve the above issue?

baduker
  • 19,152
  • 9
  • 33
  • 56
vinay kumar
  • 583
  • 6
  • 18

1 Answers1

0

You can try to execute explain command to see if Mongo uses your indexes or not.

Since you are sorting your list by date and version fields maybe you can consider Compound Indexes as well, especially sort_order part because sort order can matter in determining whether the index can support a sort operation.

Happy coding.

T.Tokic
  • 1,264
  • 9
  • 10