Uploaded image for project: 'WiredTiger'
  1. WiredTiger
  2. WT-6511

cursor join: explicitly advance the iterator when finished with a clause

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • WT10.0.0, 4.4.1, 4.7.0
    • Affects Version/s: WT3.2.1
    • Component/s: None
    • Labels:
      None

      Hi!

      We're trying to upgrade from WiredTiger from 3.1.0 to 3.2.1 and found that 'items iterated' join cursor statistics is different in these releases.

      To demonstrate I slightly modified ex_schema.c example adding function to print join cursor statistics (copied from ex_stat.c).

      diff --git a/examples/c/ex_schema.c b/examples/c/ex_schema.c
      index 0175007..812ff2b 100644
      --- a/examples/c/ex_schema.c
      +++ b/examples/c/ex_schema.c
      @@ -47,6 +47,22 @@ static POP_RECORD pop_data[] = {{"AU", 1900, 4000000}, {"AU", 1950, 8267337},
         {"USA", 1950, 150697361}, {"USA", 2000, 301279593}, {"", 0, 0}};
       /*! [schema declaration] */
       
      +/*! [statistics display function] */
      +void
      +print_cursor(WT_CURSOR *cursor)
      +{
      +    const char *desc, *pvalue;
      +    int64_t value;
      +    int ret;
      +
      +    while ((ret = cursor->next(cursor)) == 0) {
      +        error_check(cursor->get_value(cursor, &desc, &pvalue, &value));
      +        if (value != 0)
      +            printf("%s=%s\n", desc, pvalue);
      +    }
      +    scan_end_check(ret == WT_NOTFOUND);
      +}
      +
       int
       main(int argc, char *argv[])
       {
      @@ -309,6 +325,7 @@ main(int argc, char *argv[])
       
           /*! [Statistics cursor join cursor] */
           error_check(session->open_cursor(session, "statistics:join", join_cursor, NULL, &stat_cursor));
      +    print_cursor(stat_cursor);
           /*! [Statistics cursor join cursor] */
       
           error_check(stat_cursor->close(stat_cursor));
      

      On 3.1.0 I got the following output:

      $ ./ex_schema
      ...
      ID 2: country AU, year 1950, population 8267338
      ID 3: country AU, year 2000, population 19053187
      join: index:poptable:country: accesses to the main table=2
      join: index:poptable:country: checks that conditions of membership are satisfied=4
      join: index:poptable:country: items iterated=4
      ...
      

      On 3.2.1:

      $ ./ex_schema
      ...
      ID 2: country AU, year 1950, population 8267338
      ID 3: country AU, year 2000, population 19053187
      join: index:poptable:country: accesses to the main table=2
      join: index:poptable:country: checks that conditions of membership are satisfied=12
      join: index:poptable:country: items iterated=12
      ...
      

      Note the difference in "items iterated": 4 vs 12.

      This statistics is important for us since it's used to optimize subsequent queries.

      git bisect points to this commit made in WT-4946

      Thanks!

            Assignee:
            donald.anderson@mongodb.com Donald Anderson
            Reporter:
            Dmitri Shubin Dmitri Shubin
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: