You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by qi...@apache.org on 2019/07/26 01:47:20 UTC
[incubator-iotdb] branch master updated: [IOTDB-153]further limit
fetchSize to speed up LIMIT&OFFSET query (#302)
This is an automated email from the ASF dual-hosted git repository.
qiaojialin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-iotdb.git
The following commit(s) were added to refs/heads/master by this push:
new 4ac6d7e [IOTDB-153]further limit fetchSize to speed up LIMIT&OFFSET query (#302)
4ac6d7e is described below
commit 4ac6d7eb0cadab05f63732b8aa9c585e6a900d38
Author: RUI, LEI <33...@users.noreply.github.com>
AuthorDate: Fri Jul 26 09:47:16 2019 +0800
[IOTDB-153]further limit fetchSize to speed up LIMIT&OFFSET query (#302)
* further limit fetchSize to speed up LIMIT clause
---
.../java/org/apache/iotdb/jdbc/IoTDBQueryResultSet.java | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/jdbc/src/main/java/org/apache/iotdb/jdbc/IoTDBQueryResultSet.java b/jdbc/src/main/java/org/apache/iotdb/jdbc/IoTDBQueryResultSet.java
index 0c0198a..632e1b1 100644
--- a/jdbc/src/main/java/org/apache/iotdb/jdbc/IoTDBQueryResultSet.java
+++ b/jdbc/src/main/java/org/apache/iotdb/jdbc/IoTDBQueryResultSet.java
@@ -701,9 +701,10 @@ public class IoTDBQueryResultSet implements ResultSet {
}
// the next record rule without constraints
- private boolean nextWithoutConstraints() throws SQLException {
+ private boolean nextWithoutConstraints(int limitFetchSize) throws SQLException {
if ((recordItr == null || !recordItr.hasNext()) && !emptyResultSet) {
- TSFetchResultsReq req = new TSFetchResultsReq(sql, fetchSize, queryId);
+ int adaFetchSize = (limitFetchSize < fetchSize) ? limitFetchSize : fetchSize;
+ TSFetchResultsReq req = new TSFetchResultsReq(sql, adaFetchSize, queryId);
try {
TSFetchResultsResp resp = client.fetchResults(req);
@@ -743,14 +744,19 @@ public class IoTDBQueryResultSet implements ResultSet {
// When rowsOffset is constrained and the offset position has NOT been reached
if (rowsOffset != 0) {
for (int i = 0; i < rowsOffset; i++) { // Try to move to the offset position
- if (!nextWithoutConstraints()) {
+ if (!nextWithoutConstraints(rowsOffset + maxRowsOrRowsLimit - i)) {
return false; // No next record, i.e, fail to move to the offset position
}
}
rowsOffset = 0; // The offset position has been reached
}
- boolean isNext = nextWithoutConstraints();
+ boolean isNext;
+ if (maxRowsOrRowsLimit > 0) {
+ isNext = nextWithoutConstraints(maxRowsOrRowsLimit - rowsFetched);
+ } else { // maxRowsOrRowsLimit=0 means neither maxRows nor LIMIT is constrained.
+ isNext = nextWithoutConstraints(fetchSize);
+ }
if (isNext) {
/*