content/influxdb3/clustered/query-data/troubleshoot-and-optimize/report-query-performance-issues.md
Use these guidelines to work with InfluxData engineers to troubleshoot and resolve query performance issues.
[!Note]
Optimize your query
Before reporting a query performance problem, see the troubleshooting and optimization guide to learn how to optimize your query and reduce compute and memory requirements.
[!Note] Please note that this document may change from one support engagement to the next as our process and tooling improves.
As you follow these guidelines, package all produced output artifacts in the following form:
Outputs:
test-artifact-name.tar.gzSend InfluxData engineers all produced artifacts for analysis.
Currently, {{% product-name %}} doesn't provide a standardized performance test suite that you can run in your cluster. Please document your test process so that InfluxData engineers can replicate it--include the following:
Provide as much detail about your environment as your organization allows, including the following:
[!Note]
If possible, provide a synthetic dataset
If you can reproduce the performance issue with a synthetic dataset, and your process and environment are well-documented, InfluxData engineers may be able to reproduce the issue, shorten the feedback cycle, and resolve the issue sooner.
Document your the data schema to help InfluxData engineers better understand the conditions that reproduce your issue.
The most effective way to investigate query performance is to have a good understanding of the conditions in which you don't see the expected performance. Consider the following:
influxctlTest in an environment without periodic or intermittent queries to measure baseline system performance without additional query noise.
When running multiple tests with different queries, allow the system to recover between tests. Wait at least one minute after receiving a query result before executing the next query.
Perform some tests with single queries in isolation to measure baseline performance. This approach may not always reproduce your issue but can provide useful data for analysis by InfluxData engineers.
If the issue isn't replicated after reducing query noise and establishing baseline single-query performance, systematically increase query concurrency to reproduce the problem and identify the scale at which it occurs--for example, run the following test plan.
[!Note] You might need to scale the example plan up or down, as necessary, to reproduce the problem.
Your test findings and associated debug information from your Kubernetes environment can help recommend configuration changes to improve query performance as your usage scales.
<!-- Don't mention dashboards until they're working working in a future Clustered release -- ### Capture dashboard screens If you have set up alerts and dashboards for monitoring your cluster, capture screenshots of dashboard events for Queriers, Compactors, and Ingesters. -->Shortly after testing a problematic query against your InfluxDB cluster, collect the following debug information.
Outputs:
${DATETIME}-cluster-info.tar.gzDATETIME="$(date -Iminutes)"
kubectl cluster-info dump --namespace influxdb --output-directory "${DATETIME}-cluster-info/"
tar -czf "${DATETIME}-cluster-info.tar.gz" "${DATETIME}-cluster-info/"
Outputs:
app-instance.yml: Provide a copy of your AppInstance manifest.Use EXPLAIN commands
to output query plan information for a long-running query.
Outputs (InfluxQL):
explain.csvexplain-verbose.csvexplain-analyze.csvOutputs (SQL):
explain.txtexplain-verbose.txtexplain-analyze.txtIn the examples below, replace the following:
DATABASE_NAME{{% /code-placeholder-key %}}:
The name of the database to queryDATABASE_TOKEN{{% /code-placeholder-key %}}:
A database token with read permissions on the queried databaseYOUR_QUERY{{% /code-placeholder-key %}}:
Your long-running query (formatted as a single line with escaped double quotes (\")){{% code-placeholders "DATABASE_(NAME|TOKEN)|YOUR_QUERY" %}}
{{< code-tabs-wrapper >}} {{% code-tabs %}} SQL InfluxQL {{% /code-tabs %}} {{% code-tab-content %}}
influxctl \
--config config.toml \
query \
--database DATABASE_NAME \
--format table \
--token DATABASE_TOKEN \
"EXPLAIN YOUR_QUERY;" > explain.txt
{{% /code-tab-content %}} {{% code-tab-content %}}
curl --get "https://{{< influxdb/host >}}/query" \
--output "./explain.csv" \
--header "Authorization: Bearer DATABASE_TOKEN" \
--header "Accept: application/csv" \
--data-urlencode "db=DATABASE_NAME" \
--data-urlencode "q=EXPLAIN YOUR_QUERY"
{{% /code-tab-content %}} {{< /code-tabs-wrapper >}}
{{% /code-placeholders %}}
{{% code-placeholders "DATABASE_(NAME|TOKEN)|YOUR_QUERY" %}}
{{< code-tabs-wrapper >}} {{% code-tabs %}} SQL InfluxQL {{% /code-tabs %}} {{% code-tab-content %}}
influxctl \
--config config.toml \
query \
--database DATABASE_NAME \
--format table \
--token DATABASE_TOKEN \
"EXPLAIN VERBOSE YOUR_QUERY;" > explain-verbose.txt
{{% /code-tab-content %}} {{% code-tab-content %}}
curl --get "https://{{< influxdb/host >}}/query" \
--output "./explain-verbose.csv" \
--header "Authorization: Bearer DATABASE_TOKEN" \
--header "Accept: application/csv" \
--data-urlencode "db=DATABASE_NAME" \
--data-urlencode "q=EXPLAIN VERBOSE YOUR_QUERY"
{{% /code-tab-content %}} {{< /code-tabs-wrapper >}}
{{% /code-placeholders %}}
{{% code-placeholders "DATABASE_(NAME|TOKEN)|YOUR_QUERY" %}}
{{< code-tabs-wrapper >}} {{% code-tabs %}} SQL InfluxQL {{% /code-tabs %}} {{% code-tab-content %}}
influxctl \
--config config.toml \
query \
--database DATABASE_NAME \
--format table \
--token DATABASE_TOKEN \
"EXPLAIN ANALYZE YOUR_QUERY;" > explain-analyze.txt
{{% /code-tab-content %}} {{% code-tab-content %}}
curl --get "https://{{< influxdb/host >}}/query" \
--output "./explain-analyze.csv" \
--header "Authorization: Bearer DATABASE_TOKEN" \
--header "Accept: application/csv" \
--data-urlencode "db=DATABASE_NAME" \
--data-urlencode "q=EXPLAIN ANALYZE YOUR_QUERY"
{{% /code-tab-content %}} {{< /code-tabs-wrapper >}}
{{% /code-placeholders %}}
[!Warning]
May impact cluster performance
Querying InfluxDB 3 system tables may impact write and query performance of your {{< product-name omit=" Clustered" >}} cluster. Use filters to optimize queries to reduce impact to your cluster.
<!--------------- UPDATE THE DATE BELOW AS EXAMPLES ARE UPDATED --------------->System tables are subject to change
System tables are not part of InfluxDB's stable API and may change with new releases. The provided schema information and query examples are valid as of September 20, 2024. If you detect a schema change or a non-functioning query example, please submit an issue.
<!--------------- UPDATE THE DATE ABOVE AS EXAMPLES ARE UPDATED --------------->
If queries are slow for a specific table, run the following system queries to collect information for troubleshooting:
To optimize system queries, use table_name, partition_key, and
partition_id filters.
In your queries, replace the following:
TABLE_NAME{{% /code-placeholder-key %}}: the table to retrieve partitions forPARTITION_ID{{% /code-placeholder-key %}}: a partition ID (int64)PARTITION_KEY{{% /code-placeholder-key %}}: a partition key
derived from the table's partition template.
The default format is %Y-%m-%d (for example, 2024-01-01).{{% code-placeholders "TABLE_NAME" %}}
SELECT *
FROM system.tables
WHERE table_name = 'TABLE_NAME';
{{% /code-placeholders%}}
Query the system.compactor table to collect compaction information--for example, run one of the following
queries:
{{% code-placeholders "TABLE_NAME|PARTITION_KEY" %}}
SELECT *
FROM system.compactor
WHERE
table_name = 'TABLE_NAME'
AND partition_key = 'PARTITION_KEY';
{{% /code-placeholders %}}
{{% code-placeholders "TABLE_NAME|PARTITION_ID" %}}
SELECT *
FROM system.compactor
WHERE
table_name = 'TABLE_NAME'
AND partition_id = 'PARTITION_ID';
{{% /code-placeholders %}}
If the same queries are slow on more than 1 table, also run the following query to collect the size and number of partitions for all tables:
{{% code-placeholders "TABLE_NAME" %}}
SELECT table_name,
COUNT(*) as partition_count,
MAX(last_new_file_created_at) as last_new_file_created_at,
SUM(total_size_mb) as total_size_mb
FROM system.partitions
WHERE table_name IN ('foo', 'bar', 'baz')
GROUP BY table_name;
{{% /code-placeholders%}}