Documentation

Optimize querying

With data written to your cluster, you can now begin to define and test your typical query patterns and employ optimizations to ensure query performance.

Define your query patterns

Understanding your typical query patterns helps prioritize optimizations to meet your query performance requirements.

For example, consider the following questions:

  • Do you typically query data by a specific tag values?
    Apply custom partitioning to your target database or table to partition by those tags. Partitioning by commonly queried tags helps InfluxDB to quickly identify where the relevant data is in storage and improves query performance.
  • Do you query tables with wide schemas?
    Avoid using wildcards (*) in your SELECT statement. Select specific columns you want returned in your query results. The more columns queried, the less performant the query.
  • Do you query large, historical time ranges? Use time-based aggregation methods to downsample your data and return aggregate values per interval of time instead of all the data.

Decide on your query language

InfluxDB Clustered supports both SQL and InfluxQL–a SQL-like query language designed for InfluxDB v1 and specifically querying time series data.

SQL

The InfluxDB SQL implementation is a full-featured SQL query engine powered by Apache DataFusion. It benefits from a robust upstream community that is constantly improving the features and performance of the engine. Some time series-specific queries (such as time-based aggregates) are more verbose in SQL than in InfluxQL, but they are still possible.

InfluxQL

InfluxQL is designed specifically for time series data and simplifies many time series-related operations like aggregating based on time, technical analysis, and forecasting. It isn’t as full-featured as SQL and requires some understanding of the InfluxDB v1 data model.

Optimize your queries

View the query optimization and troubleshooting documentation for guidance and information on how to troubleshoot and optimize queries that do not perform as expected.

Analyze queries

Both SQL and InfluxQL support the EXPLAIN and EXPLAIN ANALYZE statements that return detailed information about your query’s planning and execution. This can provide insight into possible optimizations you can make for a specific query. For more information, see Analyze a query plan.

Custom-partition data

InfluxDB Clustered lets you define how data is stored to ensure queries are performant. Custom partitioning lets you define how InfluxDB partitions data and can be used to structure your data so it’s easier for InfluxDB to identify where the data you typically query is in storage. For more information, see Manage data partitioning.

Report query performance issues

If you’ve followed steps to optimize and troubleshoot a query, but it still doesn’t meet performance requirements, see how to report query performance issues.


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.

Read more

InfluxDB 3 Core and Enterprise are now in Beta

InfluxDB 3 Core and Enterprise are now available for beta testing, available under MIT or Apache 2 license.

InfluxDB 3 Core is a high-speed, recent-data engine that collects and processes data in real-time, while persisting it to local disk or object storage. InfluxDB 3 Enterprise is a commercial product that builds on Core’s foundation, adding high availability, read replicas, enhanced security, and data compaction for faster queries. A free tier of InfluxDB 3 Enterprise will also be available for at-home, non-commercial use for hobbyists to get the full historical time series database set of capabilities.

For more information, check out: