Uploaded image for project: 'Python Driver'
  1. Python Driver
  2. PYTHON-1747

`find_one` timed out when there is no match in the database

    • Type: Icon: Bug Bug
    • Resolution: Gone away
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 3.7.2
    • Component/s: Command Ops
    • Environment:
      macOS 10.13.6, PyCharm 2018.03.01 professional edition

      Hey guys, 

      I have an indexed db to query data with first_name, last_name and date of birth.

      filter_dict = {
          'person.last_name': last_name),
          'person.first_name': first_name),
          'person.dob':
              {'$regex': "^" + date_of_birth[:4]}
      }
      ...
      data_found = collection.find_one(filter_dict)

      It works fine when there is a match in the db, but is super slow when there is no match. The cursor returned by find() takes forever to load, which often causes time out error. However, directly executing the query in Robo 3T has no issue at all.

      I handled the time out exception and temporarily made the code work, yet this won't be a sustainable solution. Can anyone here help me find out the cause?

            Assignee:
            shane.harvey@mongodb.com Shane Harvey
            Reporter:
            dizhu_grandmoon Di Zhu
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: