<turbo-stream action="append" target="posts_list"><template>    <div class="postbit" id="357055" data-post-id="357055">
  <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>Thanks for the feedback, I love to have it. You raise some good points. I apologize if my response is long.</p>
<h3><a name="p-357055-non-indexed-filtering-and-other-query-features-1" class="anchor" href="#p-357055-non-indexed-filtering-and-other-query-features-1" aria-label="Heading link" rel="nofollow"></a>Non-indexed filtering, and other query features</h3>
<p>The benefit of us only supporting indexed <code>:where</code> clauses is that the developer knows exactly what they’re getting when they write the query. Of course we have no explain/analyze here, so I believe the role of the adapter must remain very clear to the end user. That role is: For each call to <code>Repo.all</code>, EctoFDB will always execute a single <code>get*</code> operation against FoundationDB (disregarding the IndexInventory), and do minimal processing locally. This way, the developer knows that the fact that a query works at all is confirmation that they’re getting expected performance characteristics, with respect to their chosen indexes.</p>
<p>Indeed, a downside of this is that when a new index is created, the developer must rewrite their queries to take advantage of the index. There is a risk that they miss a query and their app fails to leverage the index. I do consider this an ok tradeoff. The target audience is people that want to get “closer” to their data so-to-speak.</p>
<p>Moreover, suppose the adapter did support open ended where clauses. EctoFDB would then need to decide which index to use to conduct the query, which puts us on path to implementing a real query planner, which I’m not prepared to bite off at this point.</p>
<p>This line of thinking probably seems backwards to conventional wisdom around database querying. Most people usually want their query to do as much work as possible. For a database like Postgres, this is natural because the query computation is done within the database itself, where the sophisticated query planner can make many optimizations to carry out sorting, joining, filtering, column selection, etc, which reduces the total data that is transmitted on the network. In our case, the compute is detached from the storage, a consequence of the FDB Layer concept. This implies that you must pull a relatively large amount of data into your client and operate on it there. (And encourages your client to be as “close to” the FDB server as possible) The current design limitations of this adapter on <code>Ecto.Query</code> reflect these ideas back to the developer, so hopefully there is little doubt about the behavior.</p>
<p>One last point tangential to this topic – EctoFDB’s use of tenants is already buying 1 level of space partitioning on the data. While some relational approaches may use a foreign key for multitenancy, EctoFDB arranges the keys such that all data for a tenant is partitioned in space from others, meaning there is already an index built in, in a way.</p>
<h3><a name="p-357055-value-encoding-using-term_to_binary-2" class="anchor" href="#p-357055-value-encoding-using-term_to_binary-2" aria-label="Heading link" rel="nofollow"></a>Value encoding using <code>term_to_binary</code></h3>
<p>This is a design decision that I struggle with to be honest. There are pros and cons. BTW you’re right about the terms themselves being Keyword lists.</p>
<p>Things I like about <code>term_to_binary</code> on Keyword list:</p>
<ol>
<li>Fast and simple</li>
<li>Fairly easy to inspect and debug FDB key-value pairs outside of Ecto</li>
<li>Adding a new field is trivial. IME adding new fields is the most common schema change.</li>
<li>All Erlang terms are supported naturally</li>
</ol>
<p>Things I don’t like:</p>
<ol>
<li>Wasteful in space – all field names are stored in each value. We may someday make use of the <code>:compress</code> option, but the gains will be limited due to the unique field names.</li>
<li>Renaming fields does require a data migration, as you pointed out. In fact, EctoFDB doesn’t yet support renaming fields at all, a major gap at the moment.</li>
<li>Some Erlang terms should not be stored permanently, and EctoFDB doesn’t provide any assistance. For example, storing pids would work, but can be risky.</li>
</ol>
<p>You’ve noted some good benefits to using Protobuf. Here are some drawbacks as I see it.</p>
<ol>
<li>A headache to manage. This is more of a personal opinion on Protobuf.</li>
<li>Unclear to what extent the Ecto.Schema could be tied to a Protobuf definition. If you’re aware of any work in this space, I’m interested in hearing about it.</li>
</ol>
<p>That being said, it does seem reasonable for EctoFDB to support both term_to_binary and Protobuf (or something similar) someday, perhaps there are even use cases where it’s a choice that can be made at the <code>Ecto.Schema</code> level. However I’m not at a spot where I would implement this now. There is significant complexity, and the <code>term_to_binary</code> approach has not failed me yet. If you have a use case for Protobuf perhaps we can collaborate on some ideas in a GitHub Issue.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="357055" 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/12">Post #11</a>
	                </div>
	            </div>
              <div id="likers-container-357055" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="357055"
                     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 #11"></div>
  </section>
</div>
    <div class="postbit" id="357057" data-post-id="357057">
  <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>I recommend getting started at the “Why FoundationDB” link posted above. The classical use case here is horizontal scaling of write-heavy workloads.</p>
<p>Also there is a well-received talk from the founder about <a href="https://www.youtube.com/watch?v=4fFDFbi3toc" rel="noopener nofollow ugc">Testing Distributed Systems w/ Deterministic Simulation (YouTube)</a> that you might find interesting.</p>
<p>TBH most projects should probably just choose Postgres and move on, but there is room in the world for other databases also. For me, FoundationDB has been a pleasure to work with. Operationally, it’s rock solid. Plus you can do some cool stuff like building data structures directly on top of your data: <a href="https://hexdocs.pm/erlfdb/kv_queue.html" rel="noopener nofollow ugc">KvQueue - A distributed durable queue with erlfdb</a></p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="357057" 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/13">Post #12</a>
	                </div>
	            </div>
              <div id="likers-container-357057" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="357057"
                     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 #12"></div>
  </section>
</div>
    <div class="postbit" id="357059" data-post-id="357059">
  <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="12" 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 apologize if my response is long.</p>
</blockquote>
</aside>
<p>Absolutely not, your response is much appreciated <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"></p>
<aside class="quote no-group" data-username="jstimps" data-post="12" 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>Indeed, a downside of this is that when a new index is created, the developer must rewrite their queries to take advantage of the index.</p>
</blockquote>
</aside>
<p>To be clear, my criticism here is not a technical one - this is a UX problem. When a user is iterating on a query they might not yet know which indexes they will need, and it will harm productivity for them to rewrite all of their queries every time they make changes to the indexes. There is also a huge risk of introducing bugs every time they do this.</p>
<aside class="quote no-group" data-username="jstimps" data-post="12" 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>EctoFDB would then need to decide which index to use to conduct the query, which puts us on path to implementing a real query planner, which I’m not prepared to bite off at this point.</p>
</blockquote>
</aside>
<p>You are correct of course, and this is what I was getting at: I think it would be difficult, but well worth it. I will note that it does not need to be a particularly <em>good</em> query planner, you could probably get away with using the same index selection logic you use now and then just running everything else through <code>Stream.filter</code> in the adapter. You can improve it later, what matters is that the API is stable so you don’t have to rewrite business logic.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="357059" 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/14">Post #13</a>
	                </div>
	            </div>
              <div id="likers-container-357059" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="357059"
                     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 #13"></div>
  </section>
</div>
    <div class="postbit" id="357060" data-post-id="357060">
  <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="12" 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>This line of thinking probably seems backwards to conventional wisdom around database querying. Most people usually want their query to do as much work as possible. For a database like Postgres, this is natural because the query computation is done within the database itself, where the sophisticated query planner can make many optimizations to carry out sorting, joining, filtering, column selection, etc, which reduces the total data that is transmitted on the network. In our case, the compute is detached from the storage, a consequence of the FDB Layer concept. This implies that you must pull a relatively large amount of data into your client and operate on it there.</p>
</blockquote>
</aside>
<p>I think you have reversed cause and effect here. The reason declarative queries are the standard is not because the work is done on the server, but the other way around. Declarative queries are the standard because they are much easier to work with for most developers, for the exact reason I gave above: you don’t have to rewrite your code based on how the data is stored (i.e., in an index).</p>
<p>But this is still orthogonal to my point, which is that you should try to keep the API invariant to the schema (the indexes) so that you don’t have to rewrite business logic. The lack of predicate pushdown does not affect this equation: even if you could push down the filters it would still be slower than an index, so the query planner would be roughly the same.</p>
<p>Btw they actually <a href="https://github.com/apple/foundationdb/wiki/Everything-about-GetMappedRange" rel="noopener nofollow ugc">have added predicate pushdown</a>, though they’ve certainly made things harder on themselves by storing their records in a format the underlying database doesn’t understand (protobufs).</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="357060" 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/15">Post #14</a>
	                </div>
	            </div>
              <div id="likers-container-357060" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="357060"
                     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 #14"></div>
  </section>
</div>
    <div class="postbit" id="357061" data-post-id="357061">
  <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="12" 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 fields does require a data migration, as you pointed out.</p>
</blockquote>
</aside>
<p>The problem is more that such data migrations are impossible because you would hit the transaction limit. And even if FDB did not have such a limit, rewriting a large (even a TB) table would block for too long. Considering an FDB table could be <em>hundreds</em> of TB, and the transaction limit is 10MB, this is simply out of the question.</p>
<aside class="quote no-group" data-username="jstimps" data-post="12" 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>You’ve noted some good benefits to using Protobuf.</p>
</blockquote>
</aside>
<p>Oh I was definitely not suggesting using Protobufs, I was just citing what the Record Layer does. This is absolutely something that would require a lot of thought, especially since you have to worry about Ecto too.</p>
<p>Here’s an approach you could take: Store a schema in the FDB tenant (I assume you do something like this already?) and then assign integer ids to string fields within the schema. Update this mapping as fields are renamed or dropped.</p>
<p>Then instead of storing <code>[field: key]</code>, you can store <code>[1: key]</code> and keep the mapping <code>%{field =&gt; 1}</code> in the schema metadata. You can aggressively cache the metadata and use FDB’s special <a href="https://github.com/apple/foundationdb/pull/1213" rel="noopener nofollow ugc">metadata version key</a> to invalidate the cache (this is literally the exact thing that was added for, by the way).</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="357061" 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/16">Post #15</a>
	                </div>
	            </div>
              <div id="likers-container-357061" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="357061"
                     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 #15"></div>
  </section>
</div>
    <div class="postbit" id="357065" data-post-id="357065">
  <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="15" 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>Declarative queries are the standard because they are much easier to work with for most developers</p>
</blockquote>
</aside>
<p>While rich declarative queries do provide a better API for developers, a lot of the value I personally get from developing an app on FDB comes from a deep understanding of the data and confidence that I know precisely what the performance characteristics are of any given query, even if it means lack of an expressive query syntax. Other projects do that sort of thing much better than I could anyway!</p>
<p>I do understand all your points wrt query UX. They are solid points. I just feel that the juice isn’t worth the squeeze for me. Instead, I get more excited about exploring other data retrieval techniques such as vector similarity search. That being said, I do welcome contributions!</p>
<aside class="quote no-group" data-username="garrison" data-post="15" 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>have added predicate pushdown</p>
</blockquote>
</aside>
<p>EctoFDB uses GetMappedRange in the <a href="https://github.com/foundationdb-beam/ecto_foundationdb/blob/c45da4e7122c52c49f9b51b8209f3cb9c87882f5/lib/ecto_foundationdb/indexer/default.ex#L190" rel="noopener nofollow ugc">Default Indexer</a>.</p>
<aside class="quote no-group" data-username="garrison" data-post="16" 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>such data migrations are impossible because you would hit the transaction limit</p>
</blockquote>
</aside>
<p>Yes, impossible within a single FDB transaction. EctoFDB does provide a <a href="https://github.com/foundationdb-beam/ecto_foundationdb/blob/main/lib/ecto_foundationdb/progressive_job.ex" rel="noopener nofollow ugc">multi-transaction migration</a> for index creation. It works based on my testing but admittedly it needs more focused testing. And again, there doesn’t currently exist any schema migration. This is something I’ve been putting off that needs to be addressed. <img src="https://forum.elixirforum.com/images/emoji/apple/sweat_smile.png?v=15" title=":sweat_smile:" class="emoji" alt=":sweat_smile:" loading="lazy" width="20" height="20"></p>
<p>The Apple Record Layer also has a solution for this, at great effort. <a href="https://www.youtube.com/watch?v=HLE8chgw6LI" rel="noopener nofollow ugc">YouTube talk about it</a> (Sorry to link another YouTube video, but that’s where a lot of this info lives, sadly)</p>
<aside class="quote no-group" data-username="garrison" data-post="16" 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>Store a schema in the FDB tenant (I assume you do something like this already?)</p>
</blockquote>
</aside>
<p>Actually no, by storing the Keyword list in the value, we obviate the need to store the schema details in the database. Yes, this is limiting, but the simplicity is quite nice. We do however store the index details in the tenant – just not the schema details.</p>
<hr>
<p>If any readers have made it this far, I assume there are many recoiling in horror at this point. <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"> EctoFDB will probably never fulfill all your database needs, but for some outside-the-box use cases, I think it can be useful.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="357065" 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/17">Post #16</a>
	                </div>
	            </div>
              <div id="likers-container-357065" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="357065"
                     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 #16"></div>
  </section>
</div>
    <div class="postbit" id="357126" data-post-id="357126">
  <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="17" 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>The Apple Record Layer also has a solution for this, at great effort.</p>
</blockquote>
</aside>
<p>This trick works for building indexes because you can set them to write-only until they’re complete and the indexing operation is idempotent. The same trick would not work (naively) for a schema migration (column rename) because when you read a record you won’t know whether it was yet migrated. You could use indirection to block the entire table until the migration was complete, but again: our “table” could be <em>hundreds of terabytes</em>, so the idea of rewriting the table <em>at all</em> is out of the question. The obvious solution is to use indirection to store the column names in a schema, which is also what Record Layer does (via protobufs).</p>
<p>You could probably also do something where you instead store the schema version a record was written at and migrate them on the fly, but I think that’s both more complicated and throws away the nice compression gains from integer column ids, so why bother?</p>
<aside class="quote no-group" data-username="jstimps" data-post="17" 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>Actually no, by storing the Keyword list in the value, we obviate the need to store the schema details in the database. Yes, this is limiting, but the simplicity is quite nice. We do however store the index details in the tenant – just not the schema details.</p>
</blockquote>
</aside>
<p>Yeah, the index metadata was actually what I was referring to there - I see how that was unclear. If you want schema migrations I don’t see how you will be able to avoid storing the schema in each tenant.</p>
<p>I <em>believe</em> Apple actually uses another layer of indirection where they store a reference to a schema (which is stored in another tenant or cluster which stores schemas). It makes no difference where it’s stored because it’s cached using the metadataVersion key either way, and that key is “read” in every transaction.</p>
<aside class="quote no-group" data-username="jstimps" data-post="17" 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>EctoFDB will probably never fulfill all your database needs, but for some outside-the-box use cases, I think it can be useful.</p>
</blockquote>
</aside>
<p>I wouldn’t under-sell yourself here <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"> FDB is a very special database because it scales horizontally with strict serializability <em>and</em> it’s nearly indestructible <em>and</em> it’s permissively open-source. The biggest downside is that it’s not user-friendly, and that’s the role you’re filling. I think people would find that very useful, especially because Elixir apps are meant to “scale” and existing databases are often the bottleneck.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="357126" 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/18">Post #17</a>
	                </div>
	            </div>
              <div id="likers-container-357126" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="357126"
                     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 #17"></div>
  </section>
</div>
    <div class="postbit" id="357127" data-post-id="357127">
  <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="17" 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 get more excited about exploring other data retrieval techniques such as vector similarity search</p>
</blockquote>
</aside>
<p>I’m actually quite curious what you have in mind for this. Apple managed to build FTS indexes on FDB, but I don’t think they’ve done a vector index yet.</p>
<p>I’ve actually been thinking about how one would implement vector search on FDB’s KV model and it’s a bit tricky. IVFFlat is no good because it can’t be updated incrementally. At that point there’s little reason to bother with storing it in FDB because you can’t keep it up to date transactionally anyway.</p>
<p>HNSW supports incremental updates, but the graph approach is essentially intractable for anything except an in-memory database. The sequential retrievals would get demolished by FDB’s read latency, I think. I know there are some HNSW variants designed for disk but I’m skeptical of them (though I’m no expert here, to be clear).</p>
<p>I think the most promising approach, which has been gaining some attention lately, is to quantize the vectors heavily (1bit) and then use SIMD to brute-force search them. If they’re 1bit quantized the distance operation literally becomes <code>xor(v1, v2) |&gt; popcnt()</code>, which can be really fast. I believe Nx actually supports those operations so I’m curious what the performance would look like.</p>
<p>But most importantly it would be easy to build an index in FDB which stores <code>/index/quantized_vector/primary_key</code> and then do a reverse lookup to find the records after the quantized search. Then you can do reranking with the full vectors or with an LLM.</p>
<p>I will note that quantized approach only works well with large vectors, which makes sense: if the dimensionality is too low then too little information survives the quantization.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="357127" 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/19">Post #18</a>
	                </div>
	            </div>
              <div id="likers-container-357127" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="357127"
                     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 #18"></div>
  </section>
</div>
    <div class="postbit" id="357149" data-post-id="357149">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>This is very interesting work. Right after FoundationDB was open-sourced I tried to do something similar and created <a href="https://github.com/ananthakumaran/fdb" rel="noopener nofollow ugc">fdb</a> and experimented with <a href="https://github.com/ananthakumaran/fdb_layer" rel="noopener nofollow ugc">fdb_layer</a>. Unfortunately, I couldn’t convince any of my previous employers to use it, so it ran out of steam after some time.</p>
<p>I see a lot of parallels, good luck.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="357149" 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/20">Post #19</a>
	                </div>
	            </div>
              <div id="likers-container-357149" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="357149"
                     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 #19"></div>
  </section>
</div>
    <div class="postbit" id="357362" data-post-id="357362">
  <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>Regarding vector Index, my interest is mostly a hope at this point. Also I don’t have the time to fully invest at the moment. <img src="https://forum.elixirforum.com/images/emoji/apple/downcast_face_with_sweat.png?v=15" title=":downcast_face_with_sweat:" class="emoji" alt=":downcast_face_with_sweat:" loading="lazy" width="20" height="20"> I’ve captured my initial idea in a <a href="https://github.com/foundationdb-beam/ecto_foundationdb/discussions/35" rel="noopener nofollow ugc">new discussion here</a>. I would be interested in hearing your thoughts.</p>
<p>I’d like to continue collaborating on your other ideas too. It’s clear you have experience in this area and a bold vision. I enabled <a href="https://github.com/foundationdb-beam/ecto_foundationdb/discussions" rel="noopener nofollow ugc">Discussions</a> which may be a more convenient place to follow up on some of these conversation threads on an individual basis.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="357362" 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/21">Post #20</a>
	                </div>
	            </div>
              <div id="likers-container-357362" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="357362"
                     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 #20"></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=3">Load more posts (56 remaining)</a>
</div></template></turbo-stream>