Updated on 2025-09-04 GMT+08:00

Usage Scenarios

Scenario Description

GaussDB JDBC's streaming query mechanism processes results one by one rather than loading them all at once. It is designed for big data query scenarios with limited memory resources, such as big data export, offline analysis tasks, and pagination/on-demand loading. This mechanism helps prevent excessive memory consumption and potential memory overflow, ultimately enhancing processing speed.

Trigger Conditions

The JDBC connection parameter enableStreamingQuery is set to true. In addition, fetchSize is set to Integer.MIN_VALUE before the executeQuery method of Statement and PreparedStatement is called.

Impact on Services

Streaming query offers the following advantages:

  • Low memory consumption: Streaming query significantly reduces the memory usage of applications.
  • Fast response: Clients can start processing immediately upon receiving the first batch of data, without having to wait for the entire data set to be ready.

However, there are also associated risks:

  • Prolonged connection occupation: Streaming query requires the database connection to remain open throughout the transmission of data streams. This prolonged connection occupation may result in connection pool depletion or other resource scheduling issues.
  • Extended transaction duration: Transactions involving streaming queries may hold locks or MVCC snapshots for an extended period, increasing the probability of deadlocks or impacting write performance.

Applicable Versions

This applies only to GaussDB 505.1.0 and later versions.