Profile Query Performance

Analyze query execution steps and their performance metrics using the explain:asTable() function

Query

flowchart LR; %%{init: {"flowchart": {"defaultRenderer": "elk"}} }%% repo{{Events}} 1[(Function)] 2{{Aggregate}} 3[(Function)] result{{Result Set}} repo --> 1 1 --> 2 2 --> 3 3 --> result
logscale
x = 42
| count()
| explain:asTable(showPrefilters=false)

Introduction

The explain:asTable() function can be used to analyze query performance by providing detailed execution statistics for each step in a query plan.

In this example, the explain:asTable() function is used to profile a simple filtering and counting operation with prefilter statistics disabled.

Example incoming data might look like this:

@timestampx
2025-11-05T10:00:00Z42
2025-11-05T10:00:01Z42
2025-11-05T10:00:02Z41

Step-by-Step

  1. Starting with the source repository events.

  2. flowchart LR; %%{init: {"flowchart": {"defaultRenderer": "elk"}} }%% repo{{Events}} 1[(Function)] 2{{Aggregate}} 3[(Function)] result{{Result Set}} repo --> 1 1 --> 2 2 --> 3 3 --> result style 1 fill:#ff0000,stroke-width:4px,stroke:#000;
    logscale
    x = 42

    Filters events where the field x equals 42.

  3. flowchart LR; %%{init: {"flowchart": {"defaultRenderer": "elk"}} }%% repo{{Events}} 1[(Function)] 2{{Aggregate}} 3[(Function)] result{{Result Set}} repo --> 1 1 --> 2 2 --> 3 3 --> result style 2 fill:#ff0000,stroke-width:4px,stroke:#000;
    logscale
    | count()

    Counts the number of events that match the filter condition.

  4. flowchart LR; %%{init: {"flowchart": {"defaultRenderer": "elk"}} }%% repo{{Events}} 1[(Function)] 2{{Aggregate}} 3[(Function)] result{{Result Set}} repo --> 1 1 --> 2 2 --> 3 3 --> result style 3 fill:#ff0000,stroke-width:4px,stroke:#000;
    logscale
    | explain:asTable(showPrefilters=false)

    Generates a performance profile of the query execution, with the showPrefilters parameter set to false to exclude prefilter statistics from the output.

  5. Event Result set.

Summary and Results

The query is used to analyze the performance characteristics of a simple filtering and counting operation.

This query is useful, for example, to identify potential performance bottlenecks in queries, how events are filtered through steps, and to understand how the query is optimized.

Sample output from the incoming example data:

stepIDsteptimeMsevents
1x = *03
2x = "42"13
3count()12

Note that the profiled query plan includes an additional step (x = *) that was not present in the original query. This is because the profiling mode runs on the optimized query plan, which in this case added an extra field existence check for improved filtering performance.