Revisit how the language server derives field names for playground completions

XMLWordPrintableJSON

    • Type: Task
    • Resolution: Works as Designed
    • Priority: Minor - P4
    • No version
    • Affects Version/s: None
    • Component/s: None
    • None
    • Not Needed
    • Developer Tools

      The mongoDBService.ts runs parseSchema with a single document:

      const documents = await this._serviceProvider
      .find(
      databaseName,
      collectionName,
      {},
      { limit: 1 }
      ,
      )
      .toArray(); 

      The field names from it used for completions. There are two problems here. First, if we stay with one document then parseSchema is unnecessary overhead and we could derive the names ourselves with `Object.keys`, or by walking the document into dotted paths. Second, one document may simply not be enough, since it misses any field absent from it - whereas Compass analyzes a `$sample` of 1000 documents and uses single documents only as an incremental top-up. If we decide to sample more, we should keep parseSchema. Either way this code path runs on every completion request for a namespace, so any increase in sample size needs caching and an invalidation strategy to avoid regressing completion latency.

            Assignee:
            Alena Khineika
            Reporter:
            Alena Khineika
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: