WiredTiger: Cursor persistence

| Version 3.1.0

Fork me on GitHub Join my user group
Cursor persistence

Opening a new cursor is a relatively expensive operation in WiredTiger (especially in table objects and Log-Structured Merge Trees (LSM) trees, where a logical cursor may require multiple, underlying object cursors), and caching cursors can improve performance. On the other hand, cursors hold positions in objects, and therefore long-lived cursor positions can decrease performance by blocking page eviction or looking like a long-lived transaction.

Best practices are to cache cursors, but use the WT_CURSOR::reset method to discard the cursor's position in the object when the position is no longer needed. Additionally, use the WT_CURSOR::insert method instead of the WT_CURSOR::update method when there's no need to hold a position in the object, because the WT_CURSOR::insert method never holds a cursor position and there's no need to call WT_CURSOR::reset.