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
Do not remove.
|
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 int[] |
getPartitions() |
String |
getQueryInitiatorId() |
@Nullable 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()
Deprecated.
Use
Query.getPageSize() instead. |
boolean |
isReplicatedOnly()
Deprecated.
No longer used as of Apache Ignite 2.8.
|
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 |
setLazy(boolean lazy)
Deprecated.
Use
setPageSize(int) instead. |
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(@Nullable String schema)
Set schema for the query.
|
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 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.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)
setPageSize(int)
instead.
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()
Query.getPageSize()
instead.
See setLazy(boolean)
for more information.
@Nullable public @Nullable int[] getPartitions()
public SqlFieldsQuery setPartitions(@Nullable 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.@Nullable public @Nullable String getSchema()
public SqlFieldsQuery setSchema(@Nullable @Nullable 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()
Follow @ApacheIgnite
Ignite Database and Caching Platform : ver. 2.16.0 Release Date : December 15 2023