Local Queries

❗️

This is a legacy Apache Ignite documentation

The new documentation is hosted here: https://ignite.apache.org/docs/latest/

In some scenarios, the database can fall back from query execution in the distributed mode to the local mode. In the local mode, a query is simply passed to the underlying H2 engine which simply runs it against a node's local data set.

Those scenarios are as following:

  • If a query is executed against a REPLICATED cache on a node where the cache is deployed, then Ignite assumes that all the data is available locally and will implicitly run a simple local SQL query instead.
  • A query is executed against a LOCAL cache.
  • The local mode is explicitly enabled for a query with a special local = true parameter. Supported for native Java, .NET and C++ APIs only. For instance, in Java the parameter is switched on via the SqlFieldsQuery.setLocal(true) method.

The first two scenarios will provide you with a complete and consistent result set regardless of cluster topology changes (new node joins the cluster, or an old one leaves it) at the time of query execution.

However, the third scenario, where the local mode is enabled explicitly by your application code, should be used cautiously. If a local SQL query is executed against PARTITIONED data and a cluster topology changes in the middle, then the query might return a partial or incomplete result set because of automatic data rebalancing. The SQL engine does not handle such situations for local queries issued by applications.

If you still need to execute a local SQL query against PARTITIONED data, then consider affinity computations based technique described here.