Hi Tolga,
Probably you can use SqlQuery as is by getting a list of keys that have
to be updated with"SELECT _key FROM cache2 WHERE ..." where "_key" is
Ignite specific keyword saying that entries key has to be included into
the result set.
However since SqlQueries are broadcasted to every node (if cache mode is
PARTITIONED) the following has to be considered (can be ignored for
REPLICATED caches):
- indexes has to be properly configured for "cache2". Execution plan can
be checked with "EXPLAIN SELECT ..."
- frequency of such queries. If the query will be executed too frequent
it may affect performance.
- size of the result set. If you return tens or hundreds of keys in a
result set then it's ok but if the size is measured in thousands and
thousands of rows it may have a negative impact.
If solution with SqlQuery works fine then you can iterate over the keys
local preparing updates for cache1 and then use cache1.putAll to apply
changes.
Will this work for you?
--
Denis
On 4/4/2016 3:11 PM, Tolga Kavukcu wrote:
Hi Denis,
Thanks for the answer.
Better if i provide more detail to get a point . Lets say i have
cache1 and cache2.
- I would like to run a query on cache1. Than i should check if key
exists or not in cache2 than i will execute some logic.
I need to make sure that keys are owned by queried node so that i
could check properly if key exists in cache or not .(This can be
achieved by ScanQuery by setting partition and setLocal=true)
So if i use sql query my query would be like ;
SqlQuery sql = new SqlQuery(Person.class,"salary > ?");
I only apply one rule over one field.
But! there is no setPartition() method in SqlQuery. Please correct me
if am wrong.
Thats why i use ScanQuery to itearte over cache and apply my rule.
I will try multi-thread approach, it could speed up think. Also i
would be happy if you can suggest a faster alternative way.
Thanks.
On Mon, Apr 4, 2016 at 2:29 PM, Denis Magda <[email protected]
<mailto:[email protected]>> wrote:
Hi Tolga,
Do you really need to iterate over *all the keys* when data has to be
update? If so then you can parallelize ScanQueries when multiple local
Threads will be iterating over specific partitions on each node.
Please refer to this example for more details
https://github.com/gridgain/gridgain-advanced-examples/blob/master/src/main/java/org/gridgain/examples/datagrid/query/ScanQueryExample.java
If you don't need to iterate over every key then how would your
query look
like if you use SQL query to get a subset of the keys?
--
Denis
--
View this message in context:
http://apache-ignite-users.70518.x6.nabble.com/Running-a-query-in-only-current-nodes-partitions-tp3878p3890.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.
--
*Tolga KAVUKÇU
*