diff --git a/content/influxdb3/cloud-dedicated/query-data/execute-queries/client-libraries/python.md b/content/influxdb3/cloud-dedicated/query-data/execute-queries/client-libraries/python.md index ad173145ee..0ae8e82cbd 100644 --- a/content/influxdb3/cloud-dedicated/query-data/execute-queries/client-libraries/python.md +++ b/content/influxdb3/cloud-dedicated/query-data/execute-queries/client-libraries/python.md @@ -26,6 +26,7 @@ related: - /influxdb3/cloud-dedicated/reference/influxql/ - /influxdb3/cloud-dedicated/reference/sql/ - /influxdb3/cloud-dedicated/query-data/execute-queries/troubleshoot/ + - /influxdb3/cloud-dedicated/query-data/troubleshoot-and-optimize/query-timeout-best-practices/ list_code_example: | ```py @@ -240,7 +241,8 @@ from influxdb_client_3 import InfluxDBClient3 client = InfluxDBClient3( host='{{< influxdb/host >}}', token='DATABASE_TOKEN', - database='DATABASE_NAME' + database='DATABASE_NAME', + timeout=60 # Set default timeout to 60 seconds ) ``` {{% /code-placeholders %}} @@ -275,6 +277,7 @@ client = InfluxDBClient3( host="{{< influxdb/host >}}", token='DATABASE_TOKEN', database='DATABASE_NAME', +timeout=60, # Set default timeout to 60 seconds flight_client_options=flight_client_options( tls_root_certs=cert)) ... @@ -332,7 +335,8 @@ client = InfluxDBClient3( # Execute the query and return an Arrow table table = client.query( query="SELECT * FROM home", - language="sql" + language="sql", + timeout=30 # Override default timeout for simple queries (30 seconds) ) print("\n#### View Schema information\n") @@ -377,7 +381,8 @@ client = InfluxDBClient3( # Execute the query and return an Arrow table table = client.query( query="SELECT * FROM home", - language="influxql" + language="influxql", + timeout=30 # Override default timeout for simple queries (30 seconds) ) print("\n#### View Schema information\n") diff --git a/content/influxdb3/cloud-dedicated/query-data/execute-queries/influxctl-cli.md b/content/influxdb3/cloud-dedicated/query-data/execute-queries/influxctl-cli.md index 92d8864743..446f3d73ef 100644 --- a/content/influxdb3/cloud-dedicated/query-data/execute-queries/influxctl-cli.md +++ b/content/influxdb3/cloud-dedicated/query-data/execute-queries/influxctl-cli.md @@ -13,6 +13,7 @@ influxdb3/cloud-dedicated/tags: [query, sql, influxql, influxctl, CLI] related: - /influxdb3/cloud-dedicated/reference/cli/influxctl/query/ - /influxdb3/cloud-dedicated/get-started/query/#execute-an-sql-query, Get started querying data + - /influxdb3/cloud-dedicated/query-data/troubleshoot-and-optimize/query-timeout-best-practices/, Query timeout best practices - /influxdb3/cloud-dedicated/reference/sql/ - /influxdb3/cloud-dedicated/reference/influxql/ list_code_example: | @@ -142,6 +143,34 @@ Replace the following: - {{% code-placeholder-key %}}`DATABASE_NAME`{{% /code-placeholder-key %}}: Name of the database to query +## Query timeouts + +The [`influxctl --timeout` global flag](/influxdb3/cloud-dedicated/reference/cli/influxctl/) sets the maximum duration for API calls, including query requests. +If a query takes longer than the specified timeout, the operation will be canceled. + +### Timeout examples + +Use different timeout values based on your query type: + +{{% code-placeholders "DATABASE_(TOKEN|NAME)" %}} +```sh +# Shorter timeout for testing dashboard queries (10 seconds) +influxctl query \ + --timeout 10s \ + --token DATABASE_TOKEN \ + --database DATABASE_NAME \ + "SELECT AVG(temperature) FROM sensors WHERE time >= now() - INTERVAL '1 day'" + +# Longer timeout for analytical queries (5 minutes) +influxctl query \ + --timeout 5m \ + --token DATABASE_TOKEN \ + --database DATABASE_NAME \ + "SELECT room, AVG(temperature) FROM sensors WHERE time >= now() - INTERVAL '30 days' GROUP BY room" +``` +{{% /code-placeholders %}} + +For guidance on selecting appropriate timeout values, see [Query timeout best practices](/influxdb3/cloud-dedicated/query-data/troubleshoot-and-optimize/query-timeout-best-practices/). ## Output format @@ -243,7 +272,7 @@ influxctl query \ {{% /influxdb/custom-timestamps %}} {{< expand-wrapper >}} -{{% expand "View example results with unix nanosecond timestamps" %}} +{{% expand "View example results with Unix nanosecond timestamps" %}} {{% influxdb/custom-timestamps %}} ``` +-------+--------+---------+------+---------------------+ diff --git a/content/influxdb3/cloud-dedicated/query-data/troubleshoot-and-optimize/query-timeout-best-practices.md b/content/influxdb3/cloud-dedicated/query-data/troubleshoot-and-optimize/query-timeout-best-practices.md new file mode 100644 index 0000000000..fb4a1c8752 --- /dev/null +++ b/content/influxdb3/cloud-dedicated/query-data/troubleshoot-and-optimize/query-timeout-best-practices.md @@ -0,0 +1,17 @@ +--- +title: Query timeout best practices +description: Learn how to set appropriate query timeouts to balance performance and resource protection. +menu: + influxdb3_cloud_dedicated: + name: Query timeout best practices + parent: Troubleshoot and optimize queries +weight: 205 +related: + - /influxdb3/cloud-dedicated/reference/client-libraries/v3/ + - /influxdb3/cloud-dedicated/query-data/execute-queries/influxctl-cli/ +source: shared/influxdb3-query-guides/query-timeout-best-practices.md +--- + +