nabarun created GEODE-3804:
------------------------------

             Summary: Queries with JOIN operations are consuming exceptionally 
long amount of time for execution.
                 Key: GEODE-3804
                 URL: https://issues.apache.org/jira/browse/GEODE-3804
             Project: Geode
          Issue Type: Bug
          Components: querying
            Reporter: nabarun


The list of queries mentioned in the test case below consumed a long amount of 
time when executed over a very large dataset.
Acceptance: The test case written below must complete the execution of the 
queries within a reasonable time frame.
{code:title=JoinQueriesIntegrationTest.java}
@Category(IntegrationTest.class)
@RunWith(JUnitParamsRunner.class)
public class JoinQueriesIntegrationTest {

  public static class Customer implements Serializable {
    public int pkid;
    public int id;
    public int joinId;
    public String name;

    public Customer(int pkid, int id) {
      this.pkid = pkid;
      this.id = id;
      this.joinId = id;
      this.name = "name" + pkid;
    }

    public Customer(int pkid, int id, int joinId) {
      this.pkid = pkid;
      this.id = id;
      this.joinId = joinId;
      this.name = "name" + pkid;
    }

    public String toString() {
      return "Customer pkid = " + pkid + ", id: " + id + " name:" + name + " 
joinId: " + joinId;
    }
  }


  private static Object[] getQueryStrings() {
    return new Object[] {
        new Object[] {
            "<trace>select STA.id as STACID, STA.pkid as STAacctNum, STC.id as 
STCCID, STC.pkid as STCacctNum from /region1 STA, /region2 STC where STA.pkid = 
1 AND STA.joinId = STC.joinId AND STA.id = STC.id",
            20},
        new Object[] {
            "<trace>select STA.id as STACID, STA.pkid as STAacctNum, STC.id as 
STCCID, STC.pkid as STCacctNum from /region1 STA, /region2 STC where STA.pkid = 
1 AND STA.joinId = STC.joinId and STC.pkid = 1",
            20},
        new Object[] {
            "<trace>select STA.id as STACID, STA.pkid as STAacctNum, STC.id as 
STCCID, STC.pkid as STCacctNum from /region1 STA, /region2 STC where STA.pkid = 
1 AND  STC.pkid = 1 AND STA.joinId = STC.joinId",
            20},
        new Object[] {
            "<trace>select STA.id as STACID, STA.pkid as STAacctNum, STC.id as 
STCCID, STC.pkid as STCacctNum from /region1 STA, /region2 STC where STA.pkid = 
1 AND (STC.pkid = 0 or STC.pkid = 1) AND STA.joinId = STC.joinId",
            20},
        new Object[] {
            "<trace>select STA.id as STACID, STA.pkid as STAacctNum, STC.id as 
STCCID, STC.pkid as STCacctNum from /region1 STA, /region2 STC where STA.pkid = 
1 AND (STC.pkid = 1) AND STA.joinId = STC.joinId",
            20},
        new Object[] {
            "<trace>select STA.id as STACID, STA.pkid as STAacctNum, STC.id as 
STCCID, STC.pkid as STCacctNum from /region1 STA, /region2 STC where STA.pkid = 
1 AND STA.joinId = STC.joinId and STC.pkid = 1 and STC.name='name1'",
            20}

    };
  }

  @Test
  @Parameters(method = "getQueryStrings")
  public void testJoinTwoRegionsLargeDataSet(String queryString, int exp) 
throws Exception {
    Cache cache = CacheUtils.getCache();
    try {
      Region region1 =
          
cache.createRegionFactory().setDataPolicy(DataPolicy.REPLICATE).create("region1");
      Region region2 =
          
cache.createRegionFactory().setDataPolicy(DataPolicy.REPLICATE).create("region2");

      populateRegionWithData(region1, region2, 10000);

      QueryService queryService = cache.getQueryService();

      queryService.createIndex("pkidregion1", "p.pkid", "/region1 p");
      queryService.createIndex("pkidregion2", "p.pkid", "/region2 p");
      queryService.createIndex("indexIDRegion2", "p.id", "/region2 p");
      queryService.createIndex("indexIDRegion1", "p.id", "/region1 p");
      queryService.createIndex("joinIdregion1", "p.joinId", "/region1 p");
      queryService.createIndex("joinIdregion2", "p.joinId", "/region2 p");
      queryService.createIndex("nameIndex", "p.name", "/region2 p");

      SelectResults results = (SelectResults) 
queryService.newQuery(queryString).execute();
      int resultsSizeWithIndex = results.size();
      // assertEquals(expectedResultSize, resultsWithoutIndex);
    } finally {
      cache.getRegion("region1").destroyRegion();
      cache.getRegion("region2").destroyRegion();
    }

  }


  private void populateRegionWithData(Region region1, Region region2, int 
entryCount) {
    for (int i = 1; i < 11; i++) {
      if (i == 1 || i == 3 || i == 8 || i == 2 || i == 5) {
        region1.put(i, new Customer(1, 1, 1));
      } else {
        region1.put(i, new Customer(i, i, i));
      }
      if (i == 1 || i == 4 || i == 7 || i == 10) {
        region2.put(i, new Customer(1, 1, 1));
      } else {
        region2.put(i, new Customer(i % 5, i, i % 3));
      }
    }
  }
}

{code}



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to