Zebronix_777
Zebronix_777

Reputation: 355

Ignite cursor.getAll() takes very long time to retrieve data

I am using Ignite v2 with Java. Below is my ignite node configuration.

    CacheConfiguration<Long, MyClass> cacheCfg = new CacheConfiguration<Long, MyClass>();
    cacheCfg.setName("Test_CacheConfig");
    cacheCfg.setReadThrough(true);
    cacheCfg.setWriteThrough(true);
    cacheCfg.setIndexedTypes(Long.class, MyClass.class, Long.class, MyClass.class); 
// Two  fields of long datatype are indexed in pojo MyClass as @QuerySqlField(index=true) 
    cacheCfg.setCacheMode(CacheMode.PARTITIONED);

Using above configuration I am creating cache as,

    IgniteCache<Long, MyClass> cache = ignite.getOrCreateCache(cacheCfg);

I have a large number of records stored in this cache approx. 35 million.

I am querying this cache on two fields. field1 and field2 they both are indexed in Myclass. Ideally, the query returns only one matching record in the cursor. But when I try the read the record from the cursor using cusror.getAll().get(0) it takes around 4-5. This is way too much expensive in my scenario. Below is my query code

    SqlFieldsQuery sql = new SqlFieldsQuery(
"select *  from MyClass where field1 <= some value and maxIpVal >= some value ");
    //It returns only one record
    QueryCursor<List<?>> cursor = cache.query(sql);
    System.out.println(cursor.getAll().get(0)); // It takes time to fetch data

Note: I am putting records in cache using CacheStore. The total number of records are approximately 35 million. I have already configured JVM as recommended here https://apacheignite.readme.io/docs/jvm-and-system-tuning

Upvotes: 1

Views: 886

Answers (1)

Valentin Kulichenko
Valentin Kulichenko

Reputation: 8390

Most likely you need a group index with both fields: https://apacheignite.readme.io/docs/indexes#section-group-indexes

It is also always a good idea to look at execution plan to check what indexes are used and how the query is executed: https://apacheignite.readme.io/docs/sql-performance-and-debugging#using-explain-statement

Upvotes: 3

Related Questions