We are working with django + mongo(version 3.2) + django-rest-framework-mongoengine for one of our projects. For every string field with unique=True, UniqueValidator(of django-rest-framework-mongoengine) hits a query of {field_name: ^value$} form. This query is taking significantly more time as compared to {field_name: "value"} query. On checking the execution plan(in executionStats mode) there is huge difference between number of keysExamined in both cases. Just want to understand the reason behind it. Any help is appreciated.
Edit: Please consider value as the exact string eg: {field_name: "coffee"} vs {field_name: /^coffee$/}. I'm not able to understand why is there so much difference in performance. Regex search is not needed it's just that mongoengine is making a regex for checking exact match