<turbo-stream action="append" target="posts_list"><template>    <div class="postbit" id="357363" data-post-id="357363">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="jstimps" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/jstimps/120/37213_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  jstimps
                    <span class="op-star" title="Thread Starter">
                      <img alt="OP" class="op-star-icon" src="/assets/thread-icons/thread-icon-thread-starter-df91e872.png" />
                    </span>
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Hi! Your fdb project was very helpful in me getting the erlfdb binding tester back up and running in GitHub CI, so thank you!</p>
<p>One thing that’s unique about developing on top of FDB is that many flowers can bloom, so-to-speak. Love seeing others with interest in the tech. <img src="https://forum.elixirforum.com/images/emoji/apple/slightly_smiling_face.png?v=15" title=":slightly_smiling_face:" class="emoji" alt=":slightly_smiling_face:" loading="lazy" width="20" height="20"></p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="357363" data-batch-url="/posts/batch_likers">
                        1
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/ecto-foundationdb-an-ecto-adapter-for-foundationdb/61642/22">Post #21</a>
	                </div>
	            </div>
              <div id="likers-container-357363" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="357363"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #21"></div>
  </section>
</div>
    <div class="postbit" id="357464" data-post-id="357464">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="garrison" src="/assets/icons/user-9f439610.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  garrison
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>I don’t use gh but I will reply here if you don’t mind.</p>
<p>The only prior art I’m aware of for vector indexes on FDB is <a href="https://github.com/unum-cloud/ustore" rel="noopener nofollow ugc">this project</a>, which was posted on the FDB forums but as far as I can tell they never actually ported it to FDB before abandoning it. It’s not clear to me from the README what type of index they used, but the same org is a maintainer of a very popular SIMD vector search implementation (usearch) so it’s possible they were taking the approach I considered above.</p>
<p>SPANN is interesting, I haven’t read the paper.</p>
<p>The main reason I’m tempted by the quantize+brute-force approach is that it’s enticingly simple, and I am (naturally, as a programmer) very lazy <img src="https://forum.elixirforum.com/images/emoji/apple/slight_smile.png?v=15" title=":slight_smile:" class="emoji" alt=":slight_smile:" loading="lazy" width="20" height="20"> The complexity of HNSW and co make me very uncomfortable, especially since it doesn’t really seem like they perform <em>that</em> well. Contrast with a BTree, for instance, which is much easier to understand and yet has excellent performance (for a different use-case, of course).</p>
<p>It could very well turn out that vector search is a problem best solved by brute-force in parallel (like most of OLAP). I don’t think anyone knows for sure yet.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="357464" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/ecto-foundationdb-an-ecto-adapter-for-foundationdb/61642/23">Post #22</a>
	                </div>
	            </div>
              <div id="likers-container-357464" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="357464"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #22"></div>
  </section>
</div>
    <div class="postbit" id="358466" data-post-id="358466">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="jstimps" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/jstimps/120/37213_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  jstimps
                    <span class="op-star" title="Thread Starter">
                      <img alt="OP" class="op-star-icon" src="/assets/thread-icons/thread-icon-thread-starter-df91e872.png" />
                    </span>
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p><a class="mention" href="/u/a3kov" rel="nofollow">@a3kov</a> A quick update on your question.</p>
<p><strong>erlfdb</strong>: The erlfdb 0.2.2 release is in a real production app, working well, with a significant workload. I will consider a 1.0 release, if that is meaningful to anyone.</p>
<p><strong>ecto_foundationdb</strong>: EctoFDB is still experimental, but it is now driving a small and low-stakes production app at <a href="https://livesecret.link" rel="noopener nofollow ugc">https://livesecret.link</a> (<a href="https://github.com/jessestimpson/livesecret" rel="noopener nofollow ugc">GitHub</a>)</p>
<p>Cheers!</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="358466" data-batch-url="/posts/batch_likers">
                        2
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/ecto-foundationdb-an-ecto-adapter-for-foundationdb/61642/24">Post #23</a>
	                </div>
	            </div>
              <div id="likers-container-358466" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="358466"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #23"></div>
  </section>
</div>
    <div class="postbit" id="358481" data-post-id="358481">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="a3kov" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/a3kov/120/36235_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  a3kov
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>The inability to rename a field without rewriting the whole DB is a bit worrying… I’m not sure how much of an issue it may become, but it’s exactly the type of things that may block wider adoption of ecto_fdb.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="358481" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/ecto-foundationdb-an-ecto-adapter-for-foundationdb/61642/25">Post #24</a>
	                </div>
	            </div>
              <div id="likers-container-358481" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="358481"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #24"></div>
  </section>
</div>
    <div class="postbit" id="358488" data-post-id="358488">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="jstimps" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/jstimps/120/37213_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  jstimps
                    <span class="op-star" title="Thread Starter">
                      <img alt="OP" class="op-star-icon" src="/assets/thread-icons/thread-icon-thread-starter-df91e872.png" />
                    </span>
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>That’s a fair take. However, I believe it glosses over the difficulty in safely renaming a column in other dbs as well, as detailed in <a href="https://github.com/fly-apps/safe-ecto-migrations?tab=readme-ov-file#renaming-a-column" rel="noopener nofollow ugc">safe-ecto-migrations | Renaming a Column</a>.</p>
<p>Certainly the ecto_fdb project has a long way to go – deleting a field is table stakes, for example, and it’s not there yet. Thanks for your interest!</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="358488" data-batch-url="/posts/batch_likers">
                        1
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/ecto-foundationdb-an-ecto-adapter-for-foundationdb/61642/26">Post #25</a>
	                </div>
	            </div>
              <div id="likers-container-358488" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="358488"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #25"></div>
  </section>
</div>
    <div class="postbit" id="358489" data-post-id="358489">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="a3kov" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/a3kov/120/36235_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  a3kov
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>From the linked article:</p>
<blockquote>
<p>There is a shortcut: Don’t rename the database column, and instead rename the schema’s field name and configure it to point to the database column.</p>
</blockquote>
<p>Ecto_fdb could do the same trick I believe ? But yeah, I totally forgot about this. In 99% of cases we care about the model (schema) field names, and not about the DB column names.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="358489" data-batch-url="/posts/batch_likers">
                        1
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/ecto-foundationdb-an-ecto-adapter-for-foundationdb/61642/27">Post #26</a>
	                </div>
	            </div>
              <div id="likers-container-358489" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="358489"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #26"></div>
  </section>
</div>
    <div class="postbit" id="358787" data-post-id="358787">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="garrison" src="/assets/icons/user-9f439610.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  garrison
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="a3kov" data-post="25" data-topic="61642">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/a3kov/48/36235_2.png" class="avatar"> a3kov:</div>
<blockquote>
<p>The inability to rename a field without rewriting the whole DB is a bit worrying</p>
</blockquote>
</aside>
<p>Keep in mind the context in which I brought this up: FDB is designed to operate as a large, distributed system with a potentially enormous amount of data. The “database” layer (here, ecto_fdb) is designed to be stateless.</p>
<p>In this context, you have to take special care to use indirection for schema changes without breaking the consistency guarantees of the database and without rewriting the entire table (because, again, the table could be 100TB).</p>
<p>This is not <em>easy</em>, but it’s not impossible or anything. I don’t think it’s substantially more difficult than, for example, building indexes online (which was already implemented).</p>
<aside class="quote no-group" data-username="a3kov" data-post="27" data-topic="61642">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/a3kov/48/36235_2.png" class="avatar"> a3kov:</div>
<blockquote>
<p>Ecto_fdb could do the same trick I believe</p>
</blockquote>
</aside>
<p>This “trick” is essentially doing the indirection in the application layer. It’s inelegant because, ideally, the schema should be stored along with the data it represents. But it would work, I suppose.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="358787" data-batch-url="/posts/batch_likers">
                        1
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/ecto-foundationdb-an-ecto-adapter-for-foundationdb/61642/28">Post #27</a>
	                </div>
	            </div>
              <div id="likers-container-358787" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="358787"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #27"></div>
  </section>
</div>
    <div class="postbit" id="359264" data-post-id="359264">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="jstimps" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/jstimps/120/37213_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  jstimps
                    <span class="op-star" title="Thread Starter">
                      <img alt="OP" class="op-star-icon" src="/assets/thread-icons/thread-icon-thread-starter-df91e872.png" />
                    </span>
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="garrison" data-post="28" data-topic="61642">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/letter_avatar_proxy/v4/letter/g/3bc359/48.png" class="avatar"> garrison:</div>
<blockquote>
<p>FDB is designed to operate as a large, distributed system with a potentially enormous amount of data.</p>
</blockquote>
</aside>
<p>I actually believe the FDB design decisions work quite well for small and moderately sized databases as well. For me, it’s more about the kind of workload and the operations story. I wouldn’t want people to come away thinking that they need 100TB of data in order to use it – LiveSecret is essentially a 0-Byte database running on a couple GB of memory (please don’t try to DOS it though <img src="https://forum.elixirforum.com/images/emoji/apple/pray.png?v=15" title=":pray:" class="emoji" alt=":pray:" loading="lazy" width="20" height="20"> <img src="https://forum.elixirforum.com/images/emoji/apple/laughing.png?v=15" title=":laughing:" class="emoji" alt=":laughing:" loading="lazy" width="20" height="20">). I’m pretending FDB is an embedded database by using <a href="https://hexdocs.pm/ex_fdbmonitor/ExFdbmonitor.html" rel="noopener nofollow ugc">ex_fdbmonitor</a> , instead of SQLite, even though I am a big fan. Of course, please check FDB’s system requirements for a production app. Running with low system memory does go against the grain of a recommended FDB deployment. (8GB per fdbserver process recommended)</p>
<p>To date, the largest value add for me is never having to write DDL and never having to worry about migrations while I’m doing additive changes (new schemas, new fields, new indexes), which is 99% of development anyway IME.</p>
<aside class="quote no-group quote-modified" data-username="a3kov" data-post="27" data-topic="61642">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/a3kov/48/36235_2.png" class="avatar"> a3kov:</div>
<blockquote>
<p>Ecto_fdb could do the same trick [source option on schema field] I believe ?</p>
</blockquote>
</aside>
<p>We wouldn’t know until we tried it, to be honest. Some Ecto features come for free, and some require the adapter to meet specific contractual details. But if it doesn’t work, I imagine it would be possible to add support. Let me know if you find out!</p>
<aside class="quote no-group" data-username="jstimps" data-post="26" data-topic="61642">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/jstimps/48/37213_2.png" class="avatar"> jstimps:</div>
<blockquote>
<p>Certainly the ecto_fdb project has a long way to go – deleting a field is table stakes</p>
</blockquote>
</aside>
<p>Happy to report there is progress on the main branch, not yet in a release. Specifically, there is a new <a href="https://github.com/foundationdb-beam/ecto_foundationdb/blob/main/lib/ecto_foundationdb/cli.ex" rel="noopener nofollow ugc">CLI module</a>, a <a href="https://github.com/foundationdb-beam/ecto_foundationdb/blob/main/guides/OPERATORS.md" rel="noopener nofollow ugc">guide</a>, and a <a href="https://github.com/foundationdb-beam/ecto_foundationdb/blob/main/test/ecto/integration/cli_test.exs" rel="noopener nofollow ugc">test</a> for deleting or renaming a field safely, in the spirit of Safe Ecto Migrations. Renaming a field in this way actually requires <strong>2</strong> full table rewrites, which you may find unfortunate, but at least now it’s possible to do it <img src="https://forum.elixirforum.com/images/emoji/apple/smile.png?v=15" title=":smile:" class="emoji" alt=":smile:" loading="lazy" width="20" height="20"> .</p>
<p>Other progress on the main branch includes refactoring the IndexInventory into a general purpose metadata store. This paves the way for richer metadata such as a schema field map (like an atom table) that could allow for table operations without rewrites, similar to what’s been described in this thread. That may come in future work – I’m still considering the implications.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="359264" data-batch-url="/posts/batch_likers">
                        3
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/ecto-foundationdb-an-ecto-adapter-for-foundationdb/61642/29">Post #28</a>
	                </div>
	            </div>
              <div id="likers-container-359264" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="359264"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #28"></div>
  </section>
</div>
    <div class="postbit" id="359277" data-post-id="359277">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="garrison" src="/assets/icons/user-9f439610.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  garrison
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="jstimps" data-post="29" data-topic="61642">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/jstimps/48/37213_2.png" class="avatar"> jstimps:</div>
<blockquote>
<p>I actually believe the FDB design decisions work quite well for small and moderately sized databases as well.</p>
</blockquote>
</aside>
<p>100% agree. Even for a smaller database you get high availability/durability out of the box <em>and</em> very strong correctness and consistency guarantees (much better than Postgres, for example). Plus if you ever <em>do</em> need to scale, you know it won’t be a problem.</p>
<p>What I was getting at is that any solution for schema operations needs to be <em>able</em> to scale to 100TB+ scale in order to get full value out of FDB. Rewriting a table is fine for a (very) small DB, but not so much as you grow. <em>Especially</em> since FDB encourages a multitenant approach, and that complicates things further.</p>
<aside class="quote no-group" data-username="jstimps" data-post="29" data-topic="61642">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/jstimps/48/37213_2.png" class="avatar"> jstimps:</div>
<blockquote>
<p>Running with low system memory does go against the grain of a recommended FDB deployment. (8GB per fdbserver process recommended)</p>
</blockquote>
</aside>
<p>I have never actually operated FDB, but I struggle to think of anything in the architecture which would necessitate 8GB per process for a small DB. I would imagine this requirement is for operating at scale.</p>
<p>If the DB is small then everything is small: shard map/txnstatestore, byte sample, serverdbinfo, mutations in memory on the tlogs and in the storage ptree, etc will all be small.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="359277" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/ecto-foundationdb-an-ecto-adapter-for-foundationdb/61642/30">Post #29</a>
	                </div>
	            </div>
              <div id="likers-container-359277" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="359277"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #29"></div>
  </section>
</div>
    <div class="postbit" id="359281" data-post-id="359281">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="garrison" src="/assets/icons/user-9f439610.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  garrison
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="jstimps" data-post="29" data-topic="61642">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/jstimps/48/37213_2.png" class="avatar"> jstimps:</div>
<blockquote>
<p>Renaming a field in this way actually requires <strong>2</strong> full table rewrites, which you may find unfortunate, but at least now it’s possible to do it</p>
</blockquote>
</aside>
<p>Another thing to keep in mind is that for a large DB rewriting a table, even in the background, is actually physically expensive. FDB is a huge distributed btree, and btrees have a lot of write amplification. Rewriting the rows in order will reduce that amplification considerably (because FDB naturally batches disk updates due to the in-memory MVCC design) but even then rewriting <em>every</em> key is naturally going to wear out your SSDs, which is not free. On the cloud they will charge you iops instead, so same problem.</p>
<p>After some thought I think this design would work:</p>
<ul>
<li>Store a schema somewhere in the keyspace, perhaps in its own tenant</li>
<li>Store the ecto migration “version” under a key in the schema (transactionally) - I assume an Ecto adapter has access to this value?</li>
<li>Store a list of fields in the schema, and give each one a unique (monotonic would be fine) integer id</li>
</ul>
<p>To create a field: add a new <code>field</code> key with a new (monotonic) integer id. It is easy to allocate ids transactionally because migrations are rare so there is no contention. You can store the <code>next_id</code> in the schema.</p>
<p>To rename a field: simply point the new name to the id previously used by the old name, and then delete the old name.</p>
<p>To delete a field: well, delete the field! The id will remain “allocated” because they are monotonic.</p>
<p>So, to run a migration, we perform the above operations and then update the “schema version” to whatever Ecto provides, similar to how it works with Postgres. There should be no problem submitting this as a single transaction to FDB, as it won’t be large.</p>
<p>Naturally, you can then store rows with integer keys instead of string keys, where the integers are the above ids. You could even encode them as varints for even more space savings since there are only as many ids as fields have existed (i.e. not many).</p>
<p>Finally, for correctness you would have to read the “schema version” in every transaction to ensure it matches what the client expects. This would create a bottleneck for a large DB, but you could use the <code>\xFF/metadataVersion</code> key for cache invalidation (increment it on every migration). That key was specifically designed to do exactly this.</p>
<p>You can cache the <code>%{field =&gt; id}</code> and vice-versa mappings in an ets table (or persistent_term, perhaps, would be better) along with the Ecto version and the metadataVersion.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="359281" data-batch-url="/posts/batch_likers">
                        1
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/ecto-foundationdb-an-ecto-adapter-for-foundationdb/61642/31">Post #30</a>
	                </div>
	            </div>
              <div id="likers-container-359281" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="359281"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #30"></div>
  </section>
</div>
</template></turbo-stream><turbo-stream action="replace" target="load-more-container"><template><div id="load-more-container" class="load-more-container">
    <a class="load-more-button" data-turbo-stream="true" href="/topics/61642/load_more?page=4">Load more posts (46 remaining)</a>
</div></template></turbo-stream>