WiredTiger: File allocation

| Version 3.1.0

Fork me on GitHub Join my user group
File allocation

# File growth

It's faster on some filesystems to grow a file in chunks rather than to extend it a block at a time as new blocks are written. By configuring the wiredtiger_open functions `file_extend` value, applications can grow files ahead of the blocks being written.

error_check(wiredtiger_open(
home, NULL, "create,file_extend=(data=16MB)", &conn));

The system calls used to extend files in chunks on some systems require locking across the system call, which may decrease performance. Before configuring a `file_extend` value, before and after throughput should be carefully evaluated.

# File block allocation

By default, when file blocks are being reused, WiredTiger attempts to avoid file fragmentation by selecting the smallest available block rather than splitting a larger available block into two. The `block_allocation` configuration string to WT_SESSION::create can be set to `first` to change the algorithm to first-fit, that is, take the first available block in the file. Applications where file size is more of an issue than file fragmentation (for example, applications with fixed-size blocks) might want to configure this way.

error_check(session->create(session, "table:mytable",
"key_format=S,value_format=S,block_allocation=first"));