<story><title>The subtleties of proper B+Tree implementation</title><url>https://ayende.com/blog/198241-B/the-subtleties-of-proper-b-tree-implementation</url></story><parent_chain></parent_chain><comment><author>cperciva</author><text>Note: In most cases you don&amp;#x27;t want to split pages prior to insertion as is being done here.  Instead, you want to insert data first, and then restore the page size invariants at the end (prior to committing the operation &amp;#x2F; writing to disk &amp;#x2F; etc).  If you&amp;#x27;re doing multiple operations at once (e.g. adding new keys and deleting others) it may turn out that you can avoid the expensive page-splitting operation by postponing it.</text></comment>
<story><title>The subtleties of proper B+Tree implementation</title><url>https://ayende.com/blog/198241-B/the-subtleties-of-proper-b-tree-implementation</url></story><parent_chain></parent_chain><comment><author>travisjungroth</author><text>There’s something to generalize here. If you run out of X, split by X. This bug happens when you run out of &lt;i&gt;space&lt;/i&gt;, but split by &lt;i&gt;count&lt;/i&gt;. Author’s comment said he fixed it by splitting by size (space taken).</text></comment>