|Developing Applications with GemFire XD / Using the Procedure Provider API|
A query that is nested within a data-aware procedure may be executed on local member data, or it may be re-distributed to the GemFire XD cluster and executed on multiple GemFire XD members. The <local> and <global> escape syntax can be used to override the default behavior for nested queries.
If a data-aware procedure is invoked without specifying a WHERE clause in the CALL statement, then by default GemFire XD treats a nested query in the procedure implementation as a "global" query. This means that the nested query is distributed to the GemFire XD cluster and accesses table data from all GemFire XD members that host data for the table. Note that global queries can return duplicate results with a single procedure call, because each member that executes the procedure body invokes a separate global query.
If a procedure is invoked using a WHERE clause, then by default GemFire XD treats the nested query in the procedure implementation as a "local" query. This means that the query only accesses the local partitioned table data that is assigned to the procedure on the GemFire XD member where the procedure executes.
You can override this default behavior by specifying either the "<local>" or "<global>" escape syntax at the very beginning of a nested query string in your procedure implementation.
Connection cxn = context.getConnection(); Statement stmt = cxn.createStatement(); resultSet1 = stmt.executeQuery("<local> select * from Bar where foo > 42"); resultSet2 = stmt.executeQuery("<local> select * from Bar where foo <= 42");
When you use ON ALL to invoke a procedure, <local> queries execute only the local member for partitioned table data. However, <local> queries against replicated tables return duplicate results.