Result sets can be categorized into three types: full result sets, streaming result sets, and cursor result sets, based on the data reading method.
The following table describes the three result set types, including their advantages and disadvantages.
| Result set type | Query method | Data reading method | Advantage | Disadvantage |
|---|---|---|---|---|
| Full result set | General query | All results are read at a time. | The application code is simple. When the data volume is small, result sets of this type are read faster than those of the other two types. | The out-of-memory (OOM) error will be reported when the data volume is large. |
| Streaming result set | Streaming query | Data is read from the socket row by row rather than all at a time. | The OOM error will not occur even when the data volume is large. | The execution occupies the database for a longer time and cannot be stopped once it starts. Therefore, it may cause network congestion. |
| Cursor result set | Cursor query | Multiple rows of data are read at a time. All results are obtained through multiple reads. | The OOM error will not occur even when the data volume is large. Compared with a streaming query, a single cursor query occupies a shorter DB time. | The execution is relatively slow. Compared with a streaming query, a cursor query consumes more server resources with a longer response time. |
Note
When the text protocol is executed, full result sets are used in OceanBase Database no matter in Oracle mode or MySQL mode.
The following table lists the trigger conditions of the three result set types in MySQL mode and Oracle mode.
| Result set type | MySQL mode | Oracle mode |
|---|---|---|
| Cursor result set |
|
The &useServerPrepStmts=true or &useCursorFetch=true property is configured in the URL connection string. Note: When useCursorFetch is set to true, useServerPrepStmts will be automatically set to true. |
| Streaming result set |
|
Not supported. Note: Streaming read is no longer supported in OceanBase Connector/J V2.2.7 or later in Oracle mode. |
| Full result set | Full result sets are used unless the trigger conditions for cursor result sets or streaming result sets are met. | The &useServerPrepStmts=false property is configured in the URL connection string. |