public class SqlFieldsQuery extends Query<List<?>>
'select'
clause.
For example, in case of Word-Count example, we know that all identical words
are processed on the same cluster member, because we use the word
itself
as affinity key. This allows Ignite to execute the 'limit'
clause on
the remote nodes and bring back only the small data set specified within the 'limit' clause,
instead of the whole query result as would happen in a non-collocated execution.
IgniteCache.query(Query)
,
Serialized FormModifier and Type | Field and Description |
---|---|
static boolean |
DFLT_LAZY
Lazy mode.
|
DFLT_PAGE_SIZE
Constructor and Description |
---|
SqlFieldsQuery(SqlFieldsQuery qry)
Copy constructs SQL fields query.
|
SqlFieldsQuery(String sql)
Constructs SQL fields query.
|
SqlFieldsQuery(String sql,
boolean collocated)
Constructs SQL fields query.
|
Modifier and Type | Method and Description |
---|---|
SqlFieldsQuery |
copy() |
Object[] |
getArgs()
Gets SQL arguments.
|
@Nullable String |
getLabel()
Gets query label.
|
int[] |
getPartitions()
Gets partitions for query, in ascending order.
|
String |
getQueryInitiatorId() |
String |
getSchema()
Get schema for the query.
|
String |
getSql()
Gets SQL clause.
|
int |
getTimeout()
Gets the query execution timeout in milliseconds.
|
int |
getUpdateBatchSize()
Gets update internal bach size.
|
boolean |
isCollocated()
Checks if this query is collocated.
|
boolean |
isDistributedJoins()
Check if distributed joins are enabled for this query.
|
boolean |
isEnforceJoinOrder()
Checks if join order of tables if enforced.
|
boolean |
isLazy()
Gets lazy query execution flag.
|
boolean |
isReplicatedOnly()
Deprecated.
No longer used as of Apache Ignite 2.8.
|
boolean |
isSkipReducerOnUpdate()
Gets server side update flag.
|
static void |
resetThreadedQueryInitiatorId()
Used at the job worker to clear originator for current thread.
|
SqlFieldsQuery |
setArgs(Object... args)
Sets SQL arguments.
|
SqlFieldsQuery |
setCollocated(boolean collocated)
Sets flag defining if this query is collocated.
|
SqlFieldsQuery |
setDistributedJoins(boolean distributedJoins)
Specify if distributed joins are enabled for this query.
|
SqlFieldsQuery |
setEnforceJoinOrder(boolean enforceJoinOrder)
Sets flag to enforce join order of tables in the query.
|
SqlFieldsQuery |
setLabel(@Nullable String label)
Sets query label.
|
SqlFieldsQuery |
setLazy(boolean lazy)
Sets lazy query execution flag.
|
SqlFieldsQuery |
setLocal(boolean loc)
Sets whether this query should be executed on local node only.
|
SqlFieldsQuery |
setPageSize(int pageSize)
Sets optional page size, if
0 , then default is used. |
SqlFieldsQuery |
setPartitions(int... parts)
Sets partitions for a query.
|
SqlFieldsQuery |
setQueryInitiatorId(String qryInitiatorId) |
SqlFieldsQuery |
setReplicatedOnly(boolean replicatedOnly)
Deprecated.
No longer used as of Apache Ignite 2.8.
|
SqlFieldsQuery |
setSchema(String schema)
Set schema for the query.
|
SqlFieldsQuery |
setSkipReducerOnUpdate(boolean skipReducerOnUpdate)
Switches update mode on server side.
|
SqlFieldsQuery |
setSql(String sql)
Sets SQL clause.
|
static void |
setThreadedQueryInitiatorId(String originator)
Used at the Job worker to setup originator by default for current thread.
|
SqlFieldsQuery |
setTimeout(int timeout,
TimeUnit timeUnit)
Sets the query execution timeout.
|
SqlFieldsQuery |
setUpdateBatchSize(int updateBatchSize)
Sets update internal bach size.
|
static String |
threadedQueryInitiatorId() |
String |
toString() |
getPageSize, isLocal, prepare
public SqlFieldsQuery(SqlFieldsQuery qry)
qry
- SQL query.public SqlFieldsQuery(String sql)
sql
- SQL query.public SqlFieldsQuery(String sql, boolean collocated)
sql
- SQL query.collocated
- Collocated flag.public String getSql()
public SqlFieldsQuery setSql(String sql)
sql
- SQL clause.this
For chaining.public Object[] getArgs()
public SqlFieldsQuery setArgs(Object... args)
args
- SQL arguments.this
For chaining.public int getTimeout()
public SqlFieldsQuery setTimeout(int timeout, TimeUnit timeUnit)
timeout
- Timeout value. Zero value disables timeout.timeUnit
- Time unit.this
For chaining.public SqlFieldsQuery setSkipReducerOnUpdate(boolean skipReducerOnUpdate)
By default, when processing DML command, Ignite first fetches all affected intermediate rows for analysis to the node which initiated the query and only then forms batches of updated values to be sent to remote nodes. For simple DML commands (that however affect great deal of rows) such approach may be an overkill in terms of network delays and memory usage on initiating node. Use this flag as hint for Ignite to do all intermediate rows analysis and updates in place on corresponding remote data nodes.
IMPORTANT NOTE: There are limitations to what DML command can be optimized this way. The command containing LIMIT, OFFSET, DISTINCT, ORDER BY, GROUP BY, sub-query or UNION will be processed the usual way despite this flag setting.
Defaults to false
, meaning that intermediate results will be fetched to initiating node first.
Only affects DML commands. Ignored when Query.isLocal()
is true
.
Note that when set to true
, the query may fail in the case of even single node failure.
skipReducerOnUpdate
- Server side update flag.this
For chaining.public boolean isSkipReducerOnUpdate()
See setSkipReducerOnUpdate(boolean)
for more information.
public boolean isCollocated()
true
If the query is collocated.public SqlFieldsQuery setCollocated(boolean collocated)
collocated
- Flag value.this
For chaining.public boolean isEnforceJoinOrder()
public SqlFieldsQuery setEnforceJoinOrder(boolean enforceJoinOrder)
true
query optimizer will not reorder tables in join. By default is false
.
It is not recommended to enable this property until you are sure that your indexes and the query itself are correct and tuned as much as possible but query optimizer still produces wrong join order.
enforceJoinOrder
- Flag value.this
For chaining.public SqlFieldsQuery setDistributedJoins(boolean distributedJoins)
distributedJoins
- Distributed joins enabled.this
For chaining.public boolean isDistributedJoins()
true
If distributed joins enabled.@Nullable public @Nullable String getLabel()
null
if not set.public SqlFieldsQuery setLabel(@Nullable @Nullable String label)
The specified label can be used to identify the running query in system views and in the log when printing warnings about long-running queries.
label
- Query label, or null
to unset.this
for chaining.public SqlFieldsQuery setPageSize(int pageSize)
0
, then default is used.setPageSize
in class Query<List<?>>
pageSize
- Optional page size.this
for chaining.public SqlFieldsQuery setLocal(boolean loc)
@Deprecated public SqlFieldsQuery setReplicatedOnly(boolean replicatedOnly)
replicatedOnly
- The query contains only replicated tables.this
For chaining.@Deprecated public boolean isReplicatedOnly()
true
If the query contains only replicated tables.public SqlFieldsQuery setLazy(boolean lazy)
If lazy=false
Ignite will attempt to fetch the whole query result set to memory and send it to the client. For small
and medium result sets this provides optimal performance and minimize duration of internal database locks, thus
increasing concurrency.
If result set is too big to fit in available memory this could lead to excessive GC pauses and even
OutOfMemoryError
. Use this flag as a hint for Ignite to fetch result set lazily, thus minimizing memory
consumption at the cost of moderate performance hit.
Defaults to true
, meaning that the only first page of result set is fetched to memory.
lazy
- Lazy query execution flag.this
For chaining.public boolean isLazy()
See setLazy(boolean)
for more information.
public int[] getPartitions()
public SqlFieldsQuery setPartitions(int... parts)
Note what passed array'll be sorted in place for performance reasons, if it wasn't sorted yet.
parts
- Partitions.this
for chaining.public String getSchema()
null
if schema is not set.public SqlFieldsQuery setSchema(String schema)
schema
- Schema. null
to unset schema.this
for chaining.public int getUpdateBatchSize()
public SqlFieldsQuery setUpdateBatchSize(int updateBatchSize)
updateBatchSize
- Update internal batch size.this
for chaining.public String getQueryInitiatorId()
public SqlFieldsQuery setQueryInitiatorId(String qryInitiatorId)
qryInitiatorId
- Query's initiator identifier string (client host+port, user name,
job name or any user's information about query initiator).this
for chaining.public SqlFieldsQuery copy()
public static void setThreadedQueryInitiatorId(String originator)
originator
- Query's originator string.public static void resetThreadedQueryInitiatorId()
public static String threadedQueryInitiatorId()
GridGain In-Memory Computing Platform : ver. 8.9.14 Release Date : November 5 2024