MCPcopy Index your code
hub / github.com/MongoEngine/mongoengine / hint

Method hint

mongoengine/queryset/base.py:916–934  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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 """

Callers 4

_cursorMethod · 0.80
test_read_preferenceMethod · 0.80
test_read_concernMethod · 0.80
test_hintMethod · 0.80

Calls 1

cloneMethod · 0.95

Tested by 3

test_read_preferenceMethod · 0.64
test_read_concernMethod · 0.64
test_hintMethod · 0.64