This section explores issues related to optimizing performance of Analytics queries.
For more information about how to use Analytics functions, and for examples and best practices, see the MDEX Engine Analytics Guide.
Each of the following considerations has an impact on the Analytics query performance:
Review existing Analytics queries to understand their processing order and Analytics statement dependencies. For example, you may improve query performance if you narrow down the working record set which Analytics statements must process.
When a query contains an Analytics query, the Analytics processing is one of the last steps in the overall query processing order. The Analytics statements are calculated on the resulting record set (
NavStateRecords
) after any search, navigation, or filtering has been applied by the query. This has performance benefits, since the fewer records the Analytics statements need to process, the better.Test Analytics queries that contain a
GROUP BY
operation to measure RAM footprint and query response time. This will help identify the size of a result set that does not negatively affect performance.GROUP BY
operations result in a large number of aggregated records that are stored within the Dgraph RAM. This may cause an increase in the RAM footprint and the Dgraph processing time. It may be necessary to tuneGROUP BY
operations within Analytics statements in your queries.Build Analytics queries in a way that lets them utilize the caching of Analytics statements used in more than one query.
The Dgraph dynamic cache stores Analytics statements. If statement dependencies exist in your queries, you can utilize previously computed data within other Analytics statements. If one Analytics query includes multiple Analytics statements, each statement is cached separately, which results in a significant performance gain in cases when specific Analytics statements are shared across multiple queries.