Skip to content

Commit b09fa6d

Browse files
authored
IGNITE-28377 Removed lazy flag of SqlFieldsQuery (#12947)
1 parent f96adc8 commit b09fa6d

99 files changed

Lines changed: 230 additions & 1333 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

docs/_docs/SQL/JDBC/jdbc-driver.adoc

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,6 @@ For the list of security parameters, refer to the <<Using SSL>> section.
162162
- `jdbc:ignite:thin://myHost:11900;user=ignite;password=ignite` - connect to myHost on custom port 11900 with user credentials for authentication.
163163
- `jdbc:ignite:thin://myHost:11900;distributedJoins=true&autoCloseServerCursor=true` - connect to myHost on custom port 11900 with enabled distributed joins and autoCloseServerCursor optimization.
164164
- `jdbc:ignite:thin://myHost:11900/myschema;` - connect to myHost on custom port 11900 and access to MYSCHEMA.
165-
- `jdbc:ignite:thin://myHost:11900/"MySchema";lazy=false` - connect to myHost on custom port 11900 with disabled lazy query execution and access to MySchema (schema name is case sensitive).
166165

167166
=== Multiple Endpoints
168167

@@ -676,21 +675,3 @@ The table below lists all the link:https://en.wikipedia.org/wiki/SQLSTATE[ANSI S
676675
|50000| Internal error.
677676
The code is not defined by ANSI and refers to an Ignite specific error. Refer to the `java.sql.SQLException` error message for more information.
678677
|=======================================================================
679-
680-
681-
682-
683-
684-
685-
686-
687-
688-
689-
690-
691-
692-
693-
694-
695-
696-

docs/_docs/SQL/sql-tuning.adoc

Lines changed: 4 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -52,43 +52,10 @@ Avoid having too many columns in the result set of a `SELECT` query. Due to limi
5252

5353
== Lazy Loading
5454

55-
By default, Ignite attempts to load the whole result set to memory and send it back to the query initiator (which is usually your application).
56-
This approach provides optimal performance for queries of small or medium result sets.
57-
However, if the result set is too big to fit in the available memory, it can lead to prolonged GC pauses and even `OutOfMemoryError` exceptions.
58-
59-
To minimize memory consumption, at the cost of a moderate performance hit, you can load and process the result sets lazily by passing the `lazy` parameter to the JDBC and ODBC connection strings or use a similar method available for Java, .NET, and C++ APIs:
60-
61-
[tabs]
62-
--
63-
64-
tab:Java[]
65-
[source,java]
66-
----
67-
SqlFieldsQuery query = new SqlFieldsQuery("SELECT * FROM Person WHERE id > 10");
68-
69-
// Result set will be loaded lazily.
70-
query.setLazy(true);
71-
----
72-
tab:JDBC[]
73-
[source,sql]
74-
----
75-
jdbc:ignite:thin://192.168.0.15?lazy=true
76-
----
77-
tab:C#/.NET[]
78-
[source,csharp]
79-
----
80-
var query = new SqlFieldsQuery("SELECT * FROM Person WHERE id > 10")
81-
{
82-
// Result set will be loaded lazily.
83-
Lazy = true
84-
};
85-
----
86-
tab:C++[]
87-
--
88-
89-
////
90-
*TODO* Add tabs for ODBC and other programming languages - C# and C++
91-
////
55+
Ignite always operates in lazy loading mode. Query results are not loaded entirely into memory when possible. Data
56+
is streamed to the client in pages as the result set is iterated. The page size determines how many rows are fetched
57+
per network round trip, allowing you to balance memory consumption and performance and eliminating the risk of
58+
prolonged GC pauses and `OutOfMemoryError` exceptions for large result sets.
9259

9360
== Querying Colocated Data
9461

docs/_docs/binary-client-protocol/sql-and-scan-queries.adoc

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ UPDATE = 2
267267
|bool| Replicated only - Whether query contains only replicated tables or not.
268268
|bool| Enforce join order.
269269
|bool| Collocated - Whether your data is co-located or not.
270-
|bool| Lazy query execution.
270+
|bool| [Deprecated] Lazy query execution. This flag is not used anymore on server side.
271271
|long| Timeout (milliseconds).
272272
|bool| Include field names.
273273
|===
@@ -355,7 +355,7 @@ out.writeBoolean(false);
355355
out.writeBoolean(false);
356356
357357
// Lazy
358-
out.writeBoolean(false);
358+
out.writeBoolean(true);
359359
360360
// Timeout
361361
writeLongLittleEndian(5000, out);
@@ -631,4 +631,3 @@ readResponseHeader(in);
631631
----
632632

633633
--
634-

docs/_docs/perf-and-troubleshooting/sql-tuning.adoc

Lines changed: 4 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -78,45 +78,10 @@ with 100+ columns may perform worse than expected.
7878

7979
== Lazy Loading
8080

81-
By default, Ignite will set Lazy Loading enabled, this will minimize memory consumption at the cost of moderate performance degradation.
82-
83-
Otherwise, Ignite attempts to load the whole result set to memory and send it back to the query initiator (which is usually your application). This approach provides optimal performance for queries of small or medium result sets, and minimizes the duration of internal database locks, thus increasing concurrency.
84-
85-
WARNING, if the result set is too big to fit in the available memory, it can lead to prolonged GC pauses and even `OutOfMemoryError` exceptions. This property is deprecated since Ignite 2.15.0.
86-
87-
To change the default behavior:
88-
89-
[tabs]
90-
--
91-
92-
tab:Java[]
93-
[source,java]
94-
----
95-
SqlFieldsQuery query = new SqlFieldsQuery("SELECT * FROM Person WHERE id > 10");
96-
97-
// Result set will be loaded eagerly.
98-
query.setLazy(false);
99-
----
100-
tab:JDBC[]
101-
[source,sql]
102-
----
103-
jdbc:ignite:thin://192.168.0.15?lazy=false
104-
----
105-
tab:C#/.NET[]
106-
[source,csharp]
107-
----
108-
var query = new SqlFieldsQuery("SELECT * FROM Person WHERE id > 10")
109-
{
110-
// Result set will be loaded eagerly.
111-
Lazy = false
112-
};
113-
----
114-
tab:C++[]
115-
--
116-
117-
////
118-
*TODO* Add tabs for ODBC and other programming languages - C# and C++
119-
////
81+
Ignite always operates in lazy loading mode. Query results are not loaded entirely into memory when possible. Data
82+
is streamed to the client in pages as the result set is iterated. The page size determines how many rows are fetched
83+
per network round trip, allowing you to balance memory consumption and performance and eliminating the risk of
84+
prolonged GC pauses and `OutOfMemoryError` exceptions for large result sets.
12085

12186
== Querying Colocated Data
12287

docs/_docs/thin-clients/python-thin-client.adoc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,6 @@ The `sql()` method supports a number of parameters that
422422
| `replicated_only` |
423423
| `enforce_join_order` |
424424
| `collocated` |
425-
| `lazy` |
426425
| `include_field_names` |
427426
| `max_rows` |
428427
| `timeout` |
@@ -485,4 +484,3 @@ If you still want to use authentication without securing the connection, simply
485484
----
486485
include::{sourceFileDir}/auth.py[tag=no-ssl,indent=0]
487486
----
488-

modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/QueryRegistryImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public QueryRegistryImpl(GridKernalContext ctx) {
5858
RunningQueryManager qryMgr = kctx.query().runningQueryManager();
5959

6060
long locId = qryMgr.register(rootQry.sql(), GridCacheQueryType.SQL_FIELDS, rootQry.context().schemaName(),
61-
false, createCancelToken(qry), rootQry.initiatorId(), false, true, false);
61+
false, createCancelToken(qry), rootQry.initiatorId(), false, false);
6262

6363
rootQry.localQueryId(locId);
6464

modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/exec/ExecutionServiceImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -563,7 +563,7 @@ private FieldsQueryCursor<List<?>> executeDdl(RootQuery<Row> qry, DdlPlan plan)
563563
}
564564
else {
565565
QueryCursorImpl<List<?>> resCur = new QueryCursorImpl<>(Collections.singletonList(
566-
Collections.singletonList(0L)), null, false, false);
566+
Collections.singletonList(0L)), null, false);
567567

568568
IgniteTypeFactory typeFactory = qry.context().typeFactory();
569569

modules/clients/src/test/java/org/apache/ignite/common/RunningQueryInfoCheckInitiatorTest.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
import java.sql.Connection;
2121
import java.sql.DriverManager;
22+
import java.sql.ResultSet;
2223
import java.sql.SQLException;
2324
import java.sql.Statement;
2425
import java.util.List;
@@ -27,7 +28,6 @@
2728
import java.util.concurrent.atomic.AtomicBoolean;
2829
import java.util.function.Consumer;
2930
import java.util.regex.Pattern;
30-
3131
import org.apache.ignite.Ignite;
3232
import org.apache.ignite.Ignition;
3333
import org.apache.ignite.cache.query.FieldsQueryCursor;
@@ -227,10 +227,16 @@ public void testJdbcV2InitiatorId() throws Exception {
227227
final UUID grid0NodeId = grid(0).cluster().localNode().id();
228228

229229
GridTestUtils.runAsync(() -> {
230-
try (Connection conn = DriverManager.getConnection(CFG_URL_PREFIX + "lazy=false:nodeId="
230+
try (Connection conn = DriverManager.getConnection(CFG_URL_PREFIX + "nodeId="
231231
+ grid0NodeId + "@modules/clients/src/test/config/jdbc-security-config.xml")) {
232232
try (Statement stmt = conn.createStatement()) {
233233
stmt.execute(sql);
234+
235+
ResultSet rs = stmt.getResultSet();
236+
237+
while (rs != null && rs.next()) {
238+
// No-op.
239+
}
234240
}
235241
}
236242
catch (SQLException e) {

modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcConnectionSelfTest.java

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
import org.junit.Test;
3232

3333
import static org.apache.ignite.IgniteJdbcDriver.CFG_URL_PREFIX;
34-
import static org.apache.ignite.cache.query.SqlFieldsQuery.DFLT_LAZY;
3534

3635
/**
3736
* Connection test.
@@ -270,7 +269,6 @@ public void testSqlHints() throws Exception {
270269
assertTrue(((JdbcConnection)conn).isEnforceJoinOrder());
271270
assertFalse(((JdbcConnection)conn).isDistributedJoins());
272271
assertFalse(((JdbcConnection)conn).isCollocatedQuery());
273-
assertEquals(DFLT_LAZY, ((JdbcConnection)conn).isLazy());
274272
assertFalse(((JdbcConnection)conn).skipReducerOnUpdate());
275273
}
276274

@@ -279,7 +277,6 @@ public void testSqlHints() throws Exception {
279277
assertFalse(((JdbcConnection)conn).isEnforceJoinOrder());
280278
assertTrue(((JdbcConnection)conn).isDistributedJoins());
281279
assertFalse(((JdbcConnection)conn).isCollocatedQuery());
282-
assertEquals(DFLT_LAZY, ((JdbcConnection)conn).isLazy());
283280
assertFalse(((JdbcConnection)conn).skipReducerOnUpdate());
284281
}
285282

@@ -288,23 +285,14 @@ public void testSqlHints() throws Exception {
288285
assertFalse(((JdbcConnection)conn).isEnforceJoinOrder());
289286
assertFalse(((JdbcConnection)conn).isDistributedJoins());
290287
assertTrue(((JdbcConnection)conn).isCollocatedQuery());
291-
assertEquals(DFLT_LAZY, ((JdbcConnection)conn).isLazy());
292288
assertFalse(((JdbcConnection)conn).skipReducerOnUpdate());
293289
}
294290

295-
try (final Connection conn = DriverManager.getConnection(CFG_URL_PREFIX + "lazy=" + (!DFLT_LAZY) + "@" + configURL())) {
296-
assertFalse(((JdbcConnection)conn).isEnforceJoinOrder());
297-
assertFalse(((JdbcConnection)conn).isDistributedJoins());
298-
assertFalse(((JdbcConnection)conn).isCollocatedQuery());
299-
assertEquals(!DFLT_LAZY, ((JdbcConnection)conn).isLazy());
300-
assertFalse(((JdbcConnection)conn).skipReducerOnUpdate());
301-
}
302291
try (final Connection conn = DriverManager.getConnection(CFG_URL_PREFIX + "skipReducerOnUpdate=true@"
303292
+ configURL())) {
304293
assertFalse(((JdbcConnection)conn).isEnforceJoinOrder());
305294
assertFalse(((JdbcConnection)conn).isDistributedJoins());
306295
assertFalse(((JdbcConnection)conn).isCollocatedQuery());
307-
assertEquals(DFLT_LAZY, ((JdbcConnection)conn).isLazy());
308296
assertTrue(((JdbcConnection)conn).skipReducerOnUpdate());
309297
}
310298
}

0 commit comments

Comments
 (0)