Documentation

Query system data

InfluxDB Cloud Dedicated stores data related to queries, tables, partitions, and compaction in system tables in your cluster. Query data in your cluster’s system tables for information about your cluster.

May impact overall cluster performance

Querying InfluxDB v3 system tables may impact the overall write and query performance of your InfluxDB Cloud Dedicated cluster.

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 April 11, 2024. If you detect a schema change or a non-functioning query example, please submit an issue.

Query system tables

Querying system tables with influxctl requires influxctl v2.8.0 or newer.

Use the influxctl query command and SQL to query system tables. Provide the following:

  • Enable system tables with the --enable-system-tables command flag.

  • Database token: A database token with read permissions on the specified database. Uses the token setting from the influxctl connection profile or the --token command flag.

  • Database name: The name of the database to query information about. Uses the database setting from the influxctl connection profile or the --database command flag.

  • SQL query: The SQL query to execute. Pass the query in one of the following ways:

    • a string on the command line
    • a path to a file that contains the query
    • a single dash (-) to read the query from stdin
influxctl query \
  --enable-system-tables \
  --database 
DATABASE_NAME
\
--token
DATABASE_TOKEN
\
"
SQL_QUERY
"
influxctl query \
  --enable-system-tables \
  --database 
DATABASE_NAME
\
--token
DATABASE_TOKEN
\
/path/to/query.sql
cat ./query.sql | influxctl query \
  --enable-system-tables \
  --database 
DATABASE_NAME
\
--token
DATABASE_TOKEN
\
-

Replace the following:

  • DATABASE_TOKEN: A database token with read access to the specified database
  • DATABASE_NAME: The name of the database to query information about.
  • SQL_QUERY: The SQL query to execute. For examples, see System query examples.

When prompted, enter y to acknowledge the potential impact querying system tables may have on your cluster.

System tables

System tables are subject to change.

system.queries

The system.queries table contains an unpersisted log of queries run against the current InfluxDB Querier to which your query is routed. The query log is specific to the current Querier and is not shared across Queriers in your cluster. Logs are scoped to the specified database.

View system.queries schema

system.tables

The system.tables table contains information about tables in the specified database.

View system.tables schema

system.partitions

The system.partitions table contains information about partitions associated with the specified database.

View system.partitions schema

system.compactor

The system.compaction table contains information about compacted partition Parquet files associated with the specified database.

View system.compactor schema

System query examples

In the examples below, replace TABLE_NAME with the name of the table you want to query information about.


Query logs

View all stored query logs

SELECT * FROM system.queries

View query logs for queries with end-to-end durations above a threshold

The following returns query logs for queries with an end-to-end duration greater than 50 milliseconds.

SELECT * FROM system.queries WHERE end2end_duration::BIGINT > (50 * 1000000)

Partitions

View partition templates of all tables

SELECT * FROM system.tables

View the partition template of a specific table

SELECT * FROM system.tables WHERE table_name = '
TABLE_NAME
'

View all partitions for a table

SELECT * FROM system.partitions WHERE table_name = '
TABLE_NAME
'

View the number of partitions per table

SELECT
  table_name,
  COUNT(*) AS partition_count
FROM
  system.partitions
GROUP BY
  table_name

View the number of partitions for a specific table

SELECT
  COUNT(*) AS partition_count
FROM
  system.partitions
WHERE
  table_name = '
TABLE_NAME
'

Storage usage

View the size of tables in megabytes

SELECT
  table_name,
  SUM(total_size_mb) AS total_size_mb
FROM
  system.partitions
GROUP BY
  table_name

View the size of a specific table in megabytes

SELECT
  SUM(total_size_mb) AS total_size_mb
FROM
  system.partitions
WHERE
  table_name = '
TABLE_NAME
'

View the total size of all compacted partitions per table in bytes

SELECT
  table_name,
  SUM(total_l0_bytes) + SUM(total_l1_bytes) + SUM(total_l2_bytes) AS total_bytes
FROM
  system.compactor
GROUP BY
  table_name

View the total size of all compacted partitions in bytes

SELECT
  SUM(total_l0_bytes) + SUM(total_l1_bytes) + SUM(total_l2_bytes) AS total_bytes
FROM
  system.compactor

Compaction

View overall compaction totals for each table

SELECT
  table_name,
  SUM(total_l0_files) AS total_l0_files,
  SUM(total_l1_files) AS total_l1_files,
  SUM(total_l2_files) AS total_l2_files,
  SUM(total_l0_bytes) AS total_l0_bytes,
  SUM(total_l1_bytes) AS total_l1_bytes,
  SUM(total_l2_bytes) AS total_l2_bytes
FROM
  system.compactor
GROUP BY
  table_name

View overall compaction totals for a specific table

SELECT
  SUM(total_l0_files) AS total_l0_files,
  SUM(total_l1_files) AS total_l1_files,
  SUM(total_l2_files) AS total_l2_files,
  SUM(total_l0_bytes) AS total_l0_bytes,
  SUM(total_l1_bytes) AS total_l1_bytes,
  SUM(total_l2_bytes) AS total_l2_bytes
FROM
  system.compactor
WHERE
  table_name = '
TABLE_NAME
'

Was this page helpful?

Thank you for your feedback!


The future of Flux

Flux is going into maintenance mode. You can continue using it as you currently are without any changes to your code.

Flux is going into maintenance mode and will not be supported in InfluxDB 3.0. This was a decision based on the broad demand for SQL and the continued growth and adoption of InfluxQL. We are continuing to support Flux for users in 1.x and 2.x so you can continue using it with no changes to your code. If you are interested in transitioning to InfluxDB 3.0 and want to future-proof your code, we suggest using InfluxQL.

For information about the future of Flux, see the following: