Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-55972

Query planner should compete regular indexes against FTS indexes

    • Type: Icon: Question Question
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Query Language, Text Search
    • Labels:
      None
    • Query Optimization

      Once we are able to execute text predicates outside of an index (SERVER-17648), this ticket tracks the work to compete plans using an fts index against plans using 'normal' indexes applying the text filter afterwards.

      Original Description

      We have a collection of items with approx. 1.5 million documents. When we run this query:

      db.items.find({ "PId" : ObjectId("5ffc8133d1cd2617a4dadbf6") }).count()
      

      A value of 12 is returned i.e. there are 12 documents with the PId specified in the query. This query pretty much returns instantly.

      However, running the following query takes around 45 seconds to run and returns a value of 2:

      db.items.find({
        "PId" : ObjectId("5ffc8133d1cd2617a4dadbf6"), 
        "$text" : { "$search" : "\"average rainfall\"" } 
      }).count() 
      

      So of the 12 matching documents, 2 have average rainfall in the properties.

      So it appears that the first query does not do anything and that the text search is taking priority. Is this the case? Is this a bug or is there a way to prioritise the order in which the queries are executed?

       

       

            Assignee:
            backlog-query-optimization [DO NOT USE] Backlog - Query Optimization
            Reporter:
            ihannah@meniscus.co.uk Ian Hannah
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: