diff options
author | Keith Bostic <keith@wiredtiger.com> | 2012-12-08 19:03:02 +0000 |
---|---|---|
committer | Keith Bostic <keith@wiredtiger.com> | 2012-12-08 19:03:02 +0000 |
commit | 1981f789891da36bb58fbceb77f0802c98e82003 (patch) | |
tree | 5cff86d5597b1eb6ece7d6a3bc9342f302492a6d /examples | |
parent | becd2353b773827e627a87d2ec98c257d2fa7b9e (diff) | |
download | mongo-1981f789891da36bb58fbceb77f0802c98e82003.tar.gz |
Add wording explaining how to do index-only searches to the schema docs.
Close #150.
Diffstat (limited to 'examples')
-rw-r--r-- | examples/c/ex_schema.c | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/examples/c/ex_schema.c b/examples/c/ex_schema.c index c6becb47d11..16dfae0d046 100644 --- a/examples/c/ex_schema.c +++ b/examples/c/ex_schema.c @@ -203,7 +203,7 @@ main(void) ret = cursor->close(cursor); /*! [Return a subset of the value columns from an index] */ - /* Return the record number of the table entries using an index. */ + /* Return just the population column using an index. */ ret = session->open_cursor(session, "index:mytable:country_plus_year(population)", NULL, NULL, &cursor); while ((ret = cursor->next(cursor)) == 0) { @@ -215,17 +215,22 @@ main(void) /*! [Return a subset of the value columns from an index] */ ret = cursor->close(cursor); - /*! [Read the record number column from the composite index] */ - /* Return the record number of the table entries using an index. */ + /*! [Access only the index] */ + /* + * Avoid accessing any other column groups when using an index. + * + * It is illegal to use an empty list as the subset of the value columns + * to be returned when configuring the index cursor, the list must have + * a valid column. List a key column to avoid accessing another column + * group. + */ ret = session->open_cursor(session, - "index:mytable:country_plus_year(id)", NULL, NULL, &cursor); + "index:mytable:country_plus_year(year)", NULL, NULL, &cursor); while ((ret = cursor->next(cursor)) == 0) { cursor->get_key(cursor, &country, &year); - cursor->get_value(cursor, &recno); - printf( - "row ID %llu: country %s, year %u\n", recno, country, year); + printf("country %s, year %u\n", country, year); } - /*! [Read a subset of information from the composite index] */ + /*! [Access only the index] */ ret = cursor->close(cursor); /*! [schema complete] */ |