summaryrefslogtreecommitdiff
path: root/src/btree/row_srch.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/btree/row_srch.c')
-rw-r--r--src/btree/row_srch.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/btree/row_srch.c b/src/btree/row_srch.c
index 6169a0a810a..4afcd74520f 100644
--- a/src/btree/row_srch.c
+++ b/src/btree/row_srch.c
@@ -634,14 +634,16 @@ __wt_row_random_leaf(WT_SESSION_IMPL *session, WT_CURSOR_BTREE *cbt)
WT_INSERT *ins, **start, **stop;
WT_INSERT_HEAD *ins_head;
WT_PAGE *page;
+ uint64_t samples;
uint32_t choice, entries, i;
int level;
page = cbt->ref->page;
-
start = stop = NULL; /* [-Wconditional-uninitialized] */
entries = 0; /* [-Wconditional-uninitialized] */
+ __cursor_pos_clear(cbt);
+
/* If the page has disk-based entries, select from them. */
if (page->pg_row_entries != 0) {
cbt->compare = 0;
@@ -688,7 +690,7 @@ __wt_row_random_leaf(WT_SESSION_IMPL *session, WT_CURSOR_BTREE *cbt)
* Step down the skip list levels, selecting a random chunk of the name
* space at each level.
*/
- while (level > 0) {
+ for (samples = entries; level > 0; samples += entries) {
/*
* There are (entries) or (entries + 1) chunks of the name space
* considered at each level. They are: between start and the 1st
@@ -765,6 +767,16 @@ __wt_row_random_leaf(WT_SESSION_IMPL *session, WT_CURSOR_BTREE *cbt)
cbt->ins_head = ins_head;
cbt->compare = 0;
+ /*
+ * Random lookups in newly created collections can be slow if a page
+ * consists of a large skiplist. Schedule the page for eviction if we
+ * encounter a large skiplist. This worthwhile because applications
+ * that take a sample often take many samples, so the overhead of
+ * traversing the skip list each time accumulates to real time.
+ */
+ if (samples > 5000)
+ __wt_page_evict_soon(page);
+
return (0);
}
@@ -784,8 +796,6 @@ __wt_row_random_descent(WT_SESSION_IMPL *session, WT_CURSOR_BTREE *cbt)
btree = S2BT(session);
current = NULL;
- __cursor_pos_clear(cbt);
-
if (0) {
restart: /*
* Discard the currently held page and restart the search from