IBM Cloud Docs
Query performance

Query performance

Query performance in Discovery is dependent on a number of factors.

Evaluating performance

If you expect high simultaneous load on your application, it is important to evaluate the performance of your Discovery application. There are several dimensions commonly used to measure performance:

  1. Response latency - The time it takes for Discovery to return the results of your query.
    • Latency can vary depending on a number of factors, see Factors that impact performance for more information.
    • It is important to run tests in your production environment using a representative set of queries to determine your average latency.
  2. Query rate - The number of requests that can be processed in a given time, usually measured in Queries per Second (QPS). This measure is most important when you expect high simultaneous load on your application.
    • The rate that can be achieved varies based on many of the same factors as latency.
    • Evaluate the query rate by using representative queries at the loads you expect to see. Remember to account for peak loads during testing.

Factors that impact performance

Query performance in Discovery varies, based on many factors, including plan size, query complexity, features used, and collection size and complexity.

Plan size

Discovery pricing plans limit the number of available documents and also provide differing ability to handle query load. The larger the plan size, the more resources that are available to handle queries. The average rate limits also vary by plan size. Upgrading your plan can improve performance. See Discovery pricing plans for plans and limits.

Query complexity

There are many ways to run queries against Discovery and the different operations used can impact performance. These query characteristics can impact performance:

  1. Length - Longer queries most likely have poorer performance.
  2. Aggregations - Aggregations are a more complex query type, with nested aggregations having the highest impact on performance.
  3. Operators - Wldcarding and fuzzy matching can impact performance.
  4. Counts - Reducing the count of documents returned can improve performance; if you need to page through results, use the offset parameter.
  5. Return fields - Limiting the fields returned to only those needed for your application can help (For example, don’t return the full text of the document if only the title and passage are needed.)

See Query reference for details.

Features used

There are a number of features that enhance query results. The following features can impact performance:

  1. Passage Retrieval - Passage retrieval searches within documents to find relevant snippets of text for your query. Use the passages.fields parameter to adjust which fields in the documents that passage retrieval searches. The parameter can help reduce the latency of passage retrieval when your content has many fields. For more information about passage retrieval, see Passages.
  2. Relevancy Training - Relevancy training computes features for each top-level text field (fields at the same level as document_id in the JSON) in the collection. If there are many top level fields, this can cause a performance impact for a natural_language_query when using training. Reducing the number of top level fields can improve performance. This can be done via normalization or by manually editing the JSON to put fields that are not helpful to finding relevant content in a nested structure. Changing the fields used for training also has an impact on the model so you’ll need to consider both the impact to performance and accuracy of results if making this change. For more information about relevancy training, see Improving result relevance.
  3. Continuous Relevancy Training - Continuous relevancy training searches across all collections in an environment. The more collections in an environment, the larger the impact on performance. See Continuous Relevancy Training for more information.

Collection size and complexity

The makeup of the documents in a private collection can also impact query performance:

  1. Total number of documents - Performance might be affected when approaching the upper limits of Number of Documents for Advanced plan sizes.
  2. Size of documents - Very large documents (those several MB in size) require movement of a large amount of data per request, which can negatively impact performance especially when using passage retrieval and relevancy training.
  3. Number of enrichments - Enrichments add complexity to documents by adding a significant number of nested fields. If an enrichment is not necessary for your use case, consider disabling it at ingestion time. Enrichments are not directly used for natural_language_query search relevance. See Adding enrichments for more about information on enrichments.