Added 'hint' support, telling Mongo the proper index to use for the query. Judicious use of hints can greatly improve query performance. When doing a query on multiple fields (at least one of which is indexed) pass the indexed field as a hint to the query. H
(self, index=None)
| 914 | return queryset |
| 915 | |
| 916 | def hint(self, index=None): |
| 917 | """Added 'hint' support, telling Mongo the proper index to use for the |
| 918 | query. |
| 919 | |
| 920 | Judicious use of hints can greatly improve query performance. When |
| 921 | doing a query on multiple fields (at least one of which is indexed) |
| 922 | pass the indexed field as a hint to the query. |
| 923 | |
| 924 | Hinting will not do anything if the corresponding index does not exist. |
| 925 | The last hint applied to this cursor takes precedence over all others. |
| 926 | """ |
| 927 | queryset = self.clone() |
| 928 | queryset._hint = index |
| 929 | |
| 930 | # If a cursor object has already been created, apply the hint to it. |
| 931 | if queryset._cursor_obj: |
| 932 | queryset._cursor_obj.hint(queryset._hint) |
| 933 | |
| 934 | return queryset |
| 935 | |
| 936 | def collation(self, collation=None): |
| 937 | """ |